In Using EF6 in C# :- i have Model A which has Model B and C inside it.
class A
{
Guid Id;
B b;
C c;
public A()
{
Id = new Guid;
}
}
class B
{
Guid Id;
public B()
{
Id = new Guid;
}
}
When model A saved in database (without B and C) its working fine. When i fetch it from database and then create new B and assign it to A and try to save it. Getting error
Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.
An error occurred while saving entities that do not expose foreign key properties for their relationships. The EntityEntries property will return null because a single entity cannot be identified as the source of the exception. Handling of exceptions while saving can be made easier by exposing foreign key properties in your entity types. See the InnerException for details.
(I have all the keys as GUID).
On further debug i can see EntityKey is null for B in Exception.
I have tired this link1,link2 but non of this solution are working.