public static void Initialize(IServiceProvider serviceProvider) { using (var context = new LangDbContext( serviceProvider.GetRequiredService <DbContextOptions <LangDbContext> >())) { // Look for any movies. if (context.Langs.Any()) { return; // DB has been seeded } context.Langs.AddRange( new Lang { ID = "ru", Title = "Русский", }, new Lang { ID = "en", Title = "Английский", }, new Lang { ID = "sl", Title = "Словенский", } ); context.SaveChanges(); } }
public IActionResult Index() { var db = new LangDbContext(); ViewBag.langs = db.Langs.ToList(); return(View()); }
public Startup() { using (var client = new LangDbContext()) { //Create the database file at a path defined in SimpleDataStorage client.Database.EnsureCreated(); //Create the database tables defined in SimpleDataStorage //client.Database.Migrate(); } }
public LocalizationContext(LangDbContext db, RequestContext requestContext) { _db = db; _requestContext = requestContext; }