public void Insert_with_explicit_with_default_keys() { using var testStore = SqlServerTestStore.CreateInitialized(DatabaseName); using (var context = new BlogContextNoKeyGenerationNullableKey(testStore.Name)) { context.Database.EnsureCreatedResiliently(); context.AddRange( new NullableKeyBlog { Id = 0, Name = "One Unicorn" }, new NullableKeyBlog { Id = 1, Name = "Two Unicorns" }); context.SaveChanges(); } using (var context = new BlogContextNoKeyGenerationNullableKey(testStore.Name)) { var blogs = context.NullableKeyBlogs.OrderBy(e => e.Id).ToList(); Assert.Equal(0, blogs[0].Id); Assert.Equal(1, blogs[1].Id); } }
public void Insert_with_explicit_with_default_keys() { using (var context = new BlogContextNoKeyGenerationNullableKey(nameof(Insert_with_explicit_with_default_keys))) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.AddRange( new NullableKeyBlog { Id = 0, Name = "One Unicorn" }, new NullableKeyBlog { Id = 1, Name = "Two Unicorns" }); context.SaveChanges(); } using (var context = new BlogContextNoKeyGenerationNullableKey(nameof(Insert_with_explicit_with_default_keys))) { var blogs = context.NullableKeyBlogs.OrderBy(e => e.Id).ToList(); Assert.Equal(0, blogs[0].Id); Assert.Equal(1, blogs[1].Id); } }