public async Task ContextIsValid() { DbContextOptions <SupplyPointDataContext> options = new DbContextOptionsBuilder <SupplyPointDataContext>() .UseSqlite("Data Source=SupplyPoint.db") .Options; SupplyPointDataContext context = new SupplyPointDataContext(options); context.Database.Migrate(); Product product = await context.Products.FirstOrDefaultAsync(); }
public Action <IApplicationBuilder> Configure(Action <IApplicationBuilder> next) { // Create a new scope to retrieve scoped services using (IServiceScope scope = this.services.CreateScope()) { // Get the DbContext instance ApplicationDbContext dbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); dbContext.Database.EnsureCreated(); // Get the DbContext instance SupplyPointDataContext spContext = scope.ServiceProvider.GetRequiredService <SupplyPointDataContext>(); spContext.Database.Migrate(); } return(next); }
public ProductRepository(SupplyPointDataContext context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }
public UnitOfWork(SupplyPointDataContext dataContexts) { this.dataContext = dataContexts; }