Update primary key value using entity framework
Posted
by lemkepf
on Stack Overflow
See other posts from Stack Overflow
or by lemkepf
Published on 2009-09-02T13:41:35Z
Indexed on
2010/05/25
15:11 UTC
Read the original article
Hit count: 888
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!
© Stack Overflow or respective owner