I declare some entities like this :
Entity myEntity = new Entity();
myEntity.InnerProperties = new InnerProperties();
myEntity.OuterProperties = new OuterProperties();
When I debug the code, the Id of myEntity and both properties' Id is 0. When I run these lines :
_context.Entities.Add(myEntity);
_context.SaveChanges();
I get this exception : {"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."}
And I get this as Inner Exception :
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.
Am I getting this exception because Id's are all zero? Or am I missing something else?
One other thing is, there is an int field in Entity, I'm not filling that field. Is it the source of the exception?
Thanks.