Ejemplo n.º 1
0
        public override DataAnnotationContext CreateContext(SqlCeTestStore testStore)
        {
            var options = new DbContextOptionsBuilder(_options)
                          .UseSqlCe(testStore.Connection, b => b.ApplyConfiguration())
                          .Options;

            var context = new DataAnnotationContext(options);

            context.Database.UseTransaction(testStore.Transaction);
            return(context);
        }
Ejemplo n.º 2
0
        public override SqlCeTestStore CreateTestStore()
        => SqlCeTestStore.GetOrCreateShared(DatabaseName, () =>
        {
            var options = new DbContextOptionsBuilder(_options)
                          .UseSqlCe(_connectionString, b => b.ApplyConfiguration())
                          .Options;

            using (var context = new DataAnnotationContext(options))
            {
                context.Database.EnsureClean();
                DataAnnotationModelInitializer.Seed(context);
            }
        });
Ejemplo n.º 3
0
        public static void Seed(DataAnnotationContext context)
        {
            context.Ones.Add(new One {
                RequiredColumn = "First", RowVersion = new Guid("00000001-0000-0000-0000-000000000001")
            });
            context.Ones.Add(new One {
                RequiredColumn = "Second", RowVersion = new Guid("00000001-0000-0000-0000-000000000001")
            });

            context.Twos.Add(new Two {
                Data = "First"
            });
            context.Twos.Add(new Two {
                Data = "Second"
            });

            context.Books.Add(new Book {
                Id = "Book1"
            });

            context.SaveChanges();
        }