Reputation: 6953
I am using EF4 in VS2010 and I have the following code:
MyEntity entity = null;
entity = MyEntity.CreateMyEntity(0);
context.MyEntities.AddObject(entity);
context.AcceptAllChanges();
context.SaveChanges();
The problem is that AddObject() is not adding the object to the collection and I just can't figure out why. What happens when I step through the code is that it gets to the first property, "CityId" which is of course null and then it seems to just return from there... like it had a problem with the property being null. The only non-nullable field in my database (MSSQL) is the Id column, which is an identity column... I am quite perplexed. Please help!
Thanks in advance!
Matt
Upvotes: 0
Views: 1889