コード例 #1
0
        public DatabaseFixture()
        {
            var optBuilder = new DbContextOptionsBuilder <AddrBookDbContext>();

            optBuilder.UseNpgsql(ConnString);

            DbContext = new AddrBookDbContext(optBuilder.Options);

            DbInitializer.Initialize(DbContext, true);
        }
コード例 #2
0
ファイル: StuffService.cs プロジェクト: jmaxhu/addrbook
 /// <summary>
 /// 员工服务构造函数
 /// </summary>
 public StuffService(AddrBookDbContext context)
 {
     this.context = context;
 }
コード例 #3
0
        /// <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);
        }