Hello
I have a small ASP.NET MVC application with the following entity objects:
Person
- PersonId
- Name (string)
- FirstName (string)
- Country (Country)
Country
- CountryId
- Name
I can add and delete the entity's this works fine. I can also update name, firstname. But how can i update the country property with another country.
i was trying
p.Country = (from c in db.Country
where c.CountryId == countryId
select c).First();
but this fires an exception {"An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key."}"
even before i call SaveChanges on the datacontext.
Can someone explaind how i can update this property?
kind regards Dieter