public static void Main(string[] args) { string connectionString = ConfigurationHelper.Configuration["ConnectionStrings.DefaultNullBug"]; bool workingException = false; bool brokenException = false; using ( WorkingDbContext wctx = new WorkingDbContext( new DbContextOptionsBuilder<WorkingDbContext>().UseSqlServer( connectionString ).Options ) ) { try { wctx.Database.EnsureCreated(); } catch ( Exception e ) { Console.WriteLine( "Failed to create working context:" + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace ); workingException = true; } finally { if ( !workingException ) { Console.WriteLine( "Working context created successfully" ); } wctx.Database.EnsureDeleted(); } } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); using ( BrokenDbContext bctx = new BrokenDbContext( new DbContextOptionsBuilder<BrokenDbContext>().UseSqlServer( connectionString ).Options ) ) { try { bctx.Database.EnsureCreated(); } catch ( Exception e ) { Console.WriteLine( "Failed to create broken context:" + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace ); brokenException = true; } finally { if ( !brokenException ) { Console.WriteLine( "Broken context created successfully" ); } bctx.Database.EnsureDeleted(); } } Console.ReadLine(); }
public RoleRepository(WorkingDbContext dbContext) { _dbContext = dbContext; }
public HomeController(WorkingDbContext db) { var list = db.Roles.ToList(); }
public UserRepository(WorkingDbContext dbContext) { _dbContext = dbContext; }
/// <summary> /// 权限仓储类构造 /// </summary> /// <param name="dbContext">startup注入的数据库对象</param> public WorkItemRepository(WorkingDbContext dbContext) { _dbContext = dbContext; }
public DepartmentRepository(WorkingDbContext dbContext) { _dbContext = dbContext; }