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();
        }
示例#2
0
        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);
        }
示例#3
0
 public ProductRepository(SupplyPointDataContext context)
 {
     this.context = context ?? throw new ArgumentNullException(nameof(context));
 }
示例#4
0
 public UnitOfWork(SupplyPointDataContext dataContexts)
 {
     this.dataContext = dataContexts;
 }