Reputation: 53
I don't know how I can handle this situation, Can you help me ?
a. I insert a new record to a table
var news = new News();
News.Title = "Hello World";
myRepository.InsertNews(catId,news);
In InsertNews() function, I call myDbContext.SaveChanges(); and new record is inserted into database. In this time, I already have Id of new record.
b. After I have id of new records, I need do call other functions to process some business and get data back to update new record.
news.Metadata = newData;
and I call myDbContext.SaveChanges();
My system displays an error message. The property 'Id' is part of the object's key information and cannot be modified.
Please help me resolve this issue. Thanks
Upvotes: 0
Views: 2055
Reputation: 3606
Look at this thread :
The property 'Id' is part of the object's key information and cannot be modified
Upvotes: 1