/*public IUserInfoDal UserInfoDal { * get * { * return new UserInfoEFDal(); * } * } * public IRoleDal RoleDal { * get * { * return new RoleDal(); * } * }*/ public int saveChanges() { //只需要调用当前线程内部上下文SaveChange就完事了 DbContext dbContext = EFDbContextFactory.GetCurrentDbContext(); return(dbContext.SaveChanges()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, EFDbContextFactory <SchoolContext> contextFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc(); using (var dc = contextFactory.Create()) DbInitializer.Initialize(dc); }