Beispiel #1
0
        public void Insert_with_Identity_column()
        {
            using var testStore = SqlServerTestStore.CreateInitialized(DatabaseName);
            using (var context = new BlogContextIdentity(testStore.Name))
            {
                context.Database.EnsureCreatedResiliently();

                context.AddRange(
                    new Blog {
                    Name = "One Unicorn"
                }, new Blog {
                    Name = "Two Unicorns"
                });

                context.SaveChanges();
            }

            using (var context = new BlogContextIdentity(testStore.Name))
            {
                var blogs = context.Blogs.OrderBy(e => e.Id).ToList();

                Assert.Equal(1, blogs[0].Id);
                Assert.Equal(2, blogs[1].Id);
            }
        }
Beispiel #2
0
    public void Insert_with_Identity_column()
    {
        using (var context = new BlogContextIdentity(nameof(Insert_with_Identity_column)))
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            context.AddRange(
                new Blog {
                Name = "One Unicorn"
            }, new Blog {
                Name = "Two Unicorns"
            });

            context.SaveChanges();
        }

        using (var context = new BlogContextIdentity(nameof(Insert_with_Identity_column)))
        {
            var blogs = context.Blogs.OrderBy(e => e.Id).ToList();

            Assert.Equal(1, blogs[0].Id);
            Assert.Equal(2, blogs[1].Id);
        }
    }