Пример #1
0
        public static void Seed(IApplicationBuilder app)
        {
            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                SozlukContext sozlukContext = serviceScope.ServiceProvider.GetRequiredService <SozlukContext>();

                sozlukContext.Database.Migrate();

                if (!sozlukContext.Sozluks.Any())
                {
                    sozlukContext.Sozluks.AddRange(
                        new Sozluk()
                    {
                        Id = 1, Name = "Merhaba"
                    },
                        new Sozluk()
                    {
                        Id = 2, Name = "Eğitim"
                    },
                        new Sozluk()
                    {
                        Id = 3, Name = "Başarı"
                    },
                        new Sozluk()
                    {
                        Id = 4, Name = "Yazmak"
                    },
                        new Sozluk()
                    {
                        Id = 5, Name = "Güle Güle"
                    }
                        );

                    sozlukContext.SaveChanges();
                }
            }
        }
Пример #2
0
 public SozlukRepository(SozlukContext _sozlukContext)
 {
     sozlukContext = _sozlukContext;
 }