public DatabaseFixture() { var optBuilder = new DbContextOptionsBuilder <AddrBookDbContext>(); optBuilder.UseNpgsql(ConnString); DbContext = new AddrBookDbContext(optBuilder.Options); DbInitializer.Initialize(DbContext, true); }
/// <summary> /// 员工服务构造函数 /// </summary> public StuffService(AddrBookDbContext context) { this.context = context; }
/// <summary> /// middleware configure /// </summary> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AddrBookDbContext dbContext) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUi(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Todo API V1"); }); // 数据库初始化 DbInitializer.Initialize(dbContext); }