public void ShouldSupportGuidKeys() { var model = new GuidTestNode(); using (var context = new TestDbContext()) { context.GuidKeyModels.Add(model); context.SaveChanges(); // http://stackoverflow.com/questions/5270721/using-guid-as-pk-with-ef4-code-first Assert.IsTrue(Attribute.IsDefined(model.GetType().GetProperty("Id"), typeof(DatabaseGeneratedAttribute))); Assert.IsNotNull(model.Id); Assert.AreNotEqual(Guid.Empty, model.Id); } // simulate detach model.OneToOneOwned = new GuidOneToOneOwned(); using (var context = new TestDbContext()) { model = context.UpdateGraph(model, map => map.OwnedEntity(g => g.OneToOneOwned)); context.SaveChanges(); Assert.IsNotNull(model.OneToOneOwned); Assert.IsNotNull(model.OneToOneOwned.Id); Assert.AreNotEqual(Guid.Empty, model.OneToOneOwned.Id); } }
public void ShouldSupportAddingRootWithGuidKey() { var model = new GuidTestNode {OneToOneOwned = new GuidOneToOneOwned()}; using (var context = new TestDbContext()) { model = context.UpdateGraph(model, map => map.OwnedEntity(g => g.OneToOneOwned)); context.SaveChanges(); Assert.AreNotEqual(Guid.Empty, model.Id); Assert.IsNotNull(model.OneToOneOwned); Assert.IsNotNull(model.OneToOneOwned.Id); Assert.AreNotEqual(Guid.Empty, model.OneToOneOwned.Id); } }
public void ShouldSupportAddingRootWithGuidKey() { var model = new GuidTestNode { OneToOneOwned = new GuidOneToOneOwned() }; using (var context = new TestDbContext()) { model = context.UpdateGraph(model, map => map.OwnedEntity(g => g.OneToOneOwned)); context.SaveChanges(); Assert.AreNotEqual(Guid.Empty, model.Id); Assert.IsNotNull(model.OneToOneOwned); Assert.IsNotNull(model.OneToOneOwned.Id); Assert.AreNotEqual(Guid.Empty, model.OneToOneOwned.Id); } }