예제 #1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity <Store>().HasOne(x => x.Address).WithOne(x => x !.Store !).HasForeignKey <Address>(x => x.StoreId);

            modelBuilder.Entity <Country>().HasData(CountrySeed.Get());
            modelBuilder.Entity <Company>().HasData(CompanySeed.Get());
            modelBuilder.Entity <Address>().HasData(AddressSeed.Get());
            modelBuilder.Entity <Store>().HasData(StoreSeed.Get());
            modelBuilder.Entity <Product>().HasData(ProductSeed.Get());
        }
예제 #2
0
        protected override void Seed(TestDbContext context)
        {
            base.Seed(context);

            var companies = CompanySeed.Get();

            context.Addresses.AddRange(AddressSeed.Get());
            context.Countries.AddRange(CountrySeed.Get());
            context.Companies.AddRange(CompanySeed.Get());
            context.Products.AddRange(ProductSeed.Get());
            context.Stores.AddRange(StoreSeed.Get());

            context.SaveChanges();
        }