public void Insert_with_server_generated_GUID_key() { using var testStore = NpgsqlTestStore.CreateInitialized(DatabaseName); Guid afterSave; using (var context = new BlogContextServerGuidKey(testStore.Name)) { context.Database.EnsureCreated(); var blog = context.Add( new GuidBlog { Name = "One Unicorn" }).Entity; var beforeSave = blog.Id; var beforeSaveNotId = blog.NotId; Assert.Equal(default, beforeSave);
public void Insert_with_server_generated_GUID_key() { using (var testStore = SqlServerTestStore.CreateInitialized(DatabaseName)) { Guid afterSave; using (var context = new BlogContextServerGuidKey(testStore.Name)) { context.Database.EnsureCreated(); var blog = context.Add(new GuidBlog { Name = "One Unicorn" }).Entity; var beforeSave = blog.Id; var beforeSaveNotId = blog.NotId; Assert.NotEqual(default(Guid), beforeSave); Assert.Equal(default(Guid), beforeSaveNotId); context.SaveChanges(); afterSave = blog.Id; var afterSaveNotId = blog.NotId; Assert.NotEqual(default(Guid), afterSave); Assert.NotEqual(default(Guid), afterSaveNotId); Assert.NotEqual(beforeSave, afterSave); Assert.NotEqual(beforeSaveNotId, afterSaveNotId); } using (var context = new BlogContextServerGuidKey(testStore.Name)) { Assert.Equal(afterSave, context.GuidBlogs.Single().Id); } } }