title: Entity Framework: ObjectSet.AddObject not adding the entity?
body: <p>I am using EF4 in VS2010 and I have the following code:</p>
  
  <pre><code>MyEntity entity = null;
  entity = MyEntity.CreateMyEntity(0);
  context.MyEntities.AddObject(entity);
  context.AcceptAllChanges();
  context.SaveChanges();
  </code></pre>
  
  <p>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!</p>
  
  <p>Thanks in advance!</p>
  
  <p>Matt</p>