Пример #1
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     //Define entity framework, adding sqlite driver and dbContext
     services.AddEntityFramework().AddSqlite().AddDbContext<MyDbContext>();
     //create dbContext without dependency injection;
     context = new MyDbContext();
     context.Database.EnsureCreated();
     //create a test user everytime the application starts - just for testing
     this.CreateSampleDatabaseEntry();
 }
 public HomeController(MyDbContext context){
     dbContext = context;
 }