Exemple #1
0
        public static void Seed(IApplicationBuilder applicationBuilder)
        {
            IAppDbContext context = applicationBuilder.ApplicationServices.GetRequiredService <AppDbContext>();

            if (!context.Products.Any())
            {
                context.AddRange
                (
                    new Product
                {
                    ProductId = 1,
                    Name      = "Moving",
                    Price     = 800
                },
                    new Product
                {
                    ProductId = 2,
                    Name      = "Packing",
                    Price     = 400
                },
                    new Product
                {
                    ProductId = 3,
                    Name      = "Cleaning",
                    Price     = 300
                }
                );
            }

            if (!context.Customers.Any())
            {
                context.AddRange
                (
                    new Customer
                {
                    CustomerId = 1,
                    Name       = "Ole",
                    PhoneNo    = "444 00 999",
                    Email      = "ole@me"
                },
                    new Customer
                {
                    CustomerId = 2,
                    Name       = "Mari",
                    PhoneNo    = "444 00 991",
                    Email      = "mari@me"
                }
                );
            }

            context.SaveChanges();
        }
Exemple #2
0
 public void AddRange(IEnumerable <T> entities)
 {
     context.AddRange(entities);
 }
Exemple #3
0
        private bool TrySeedDevelopers()
        {
            if (_appDbContext.Developers.Any())
            {
                return(false);
            }

            _appDbContext.AddRange(
                new[]
            {
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Pavel Petrov",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Dastan Uskembayev",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Azamat Kazhgali",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "Sergey Molotkov",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Rustem Makhanov",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "Daniyar Kokabayev",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "Mikhail Kazakov",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "Sergey Borisov",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "Alexey Ershov",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Евгений Ступин",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "Dmitry Zarubin",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Mobile,
                    FullName = "ilya mazurenko",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Khadzhimustafov Alexey",
                    UserName = "******"
                },
                new Developer
                {
                    Team     = Team.Desktop,
                    FullName = "Ruslan Aliev",
                    UserName = "******"
                }
            });

            return(true);
        }