Update primary key value using entity framework
- by lemkepf
I'm trying to update one value of a compound primary key from within the entity framework and I'm getting this error: "The property 'CustomerID' is part of the object's key information and cannot be modified. "
Here is my code:
Dim customer As Customer = (From c In db.Customer Where c.CustomerID = "xxx" AndAlso c.SiteKey = siteKey).FirstOrDefault
customer.CustomerID = "fasdfasdf"
db.SaveChanges()
It seems too simple. Is it true you can't update a primary key within the entity framework? I can't find any documentation on the topic. Thanks!