Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

"The property 'ID' is part of the object's key information and cannot be modified

$
0
0

Hi All, 

I'm facing the problem with the Entity framework project. at the beginning of the project, I made an update method to perform on update from my entity framework, but somehow after working on other modules, the update method suddenly doesn't allow me to perform an update anymore.

    private void DischargeButton_Click(object sender, RoutedEventArgs e)
        {


            OVDomainContext = new OfficeVisitDS();
          
            EntityQuery<Office_visit> bb = from b in OVDomainContext.GetOffice_visitQuery() where b.OV_ID == Convert.ToInt32(oV_IDTextBox.Text) select b;
            LoadOperation<Office_visit> res = OVDomainContext.Load(bb, new Action<LoadOperation<Office_visit>>(getOfficeVisitCompleted), true);
        }

        private void getOfficeVisitCompleted(LoadOperation<Office_visit> obj)
        {
            Office_visit blah = obj.Entities.First();
           // Office_visit blah = obj.Entities.FirstOrDefault(b => b.OV_ID== Convert.ToInt32(oV_IDTextBox.Text));
            blah.discharged = true;
            blah.timeend = DateTime.Now;
            //blah.OV_ID =Convert.ToInt32( OVDomainContext.Office_visits.First(b => b.OV_ID == blah.OV_ID));
            blah.OV_ID = Convert.ToInt32(oV_IDTextBox.Text);
            OVDomainContext.SubmitChanges();
        }

Here's basically what its looks like. 

my closest possible suspect is that entity framework also think that i'm going to update the OV_ID which is the primary key in the database. but I don't know how to perform any other way to do this. 

 


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>