예제 #1
0
        public static void PopulateDatabase()
        {
            using var context = new CustomersContext(quiet: true);

            context.AddRange(
                new Review
            {
                Title       = "My yellow kettle",
                Description = "Awesome!",
                Rating      = 5.0f
            },
                new Review
            {
                Title       = "My TV",
                Description = "Would be nice if it didn't keep switching to German.",
                Rating      = 2.0f
            },
                new Review
            {
                Title       = "Big bed",
                Description = "Good, but hard to put together",
                Rating      = 3.5f
            });

            context.SaveChanges();
        }
 public async Task Seed()
 {
     if (!_context.Types.Any())
     {
         _context.AddRange(_types);
         await _context.SaveChangesAsync();
     }
 }
예제 #3
0
        public static void CreateSeedData(this CustomersContext context, int records = 1000)
        {
            if (context.Customers.Any())
            {
                return;
            }

            var customers = LoadCustomers(records);

            context.AddRange(customers);
            context.SaveChanges();
        }
        public static void PopulateDatabase()
        {
            using var context = new CustomersContext(quiet: true);

            context.AddRange(
                new Customer
            {
                Name = "Arthur"
            },
                new Customer
            {
                Name = "Alan"
            },
                new Customer
            {
                Name = "Andrew"
            });

            context.SaveChanges();
        }