public IDbContext GetDbContext() { //if (_dbContext != null) //{ // return _dbContext; //} try { _dbContext = new SpSynthDbContext(); //if (!_dbContext.Database.Exists()) //{ // Database.SetInitializer(new SpSynthDbInitializer()); //} //else //{ // Database.SetInitializer(new MigrateDatabaseToLatestVersion<SpSynthDbContext, SpSynthMigrationConfig>()); //} Database.SetInitializer(new SpSynthDbInitializer()); _dbContext.Database.Initialize(true); } catch (Exception ex) { Logger.Error(ex); } return _dbContext; }
public IDbContext GetDbContext() { //if (_dbContext != null) //{ // return _dbContext; //} try { _dbContext = new SpSynthDbContext(); //if (!_dbContext.Database.Exists()) //{ // Database.SetInitializer(new SpSynthDbInitializer()); //} //else //{ // Database.SetInitializer(new MigrateDatabaseToLatestVersion<SpSynthDbContext, SpSynthMigrationConfig>()); //} Database.SetInitializer(new SpSynthDbInitializer()); _dbContext.Database.Initialize(true); } catch (Exception ex) { Logger.Error(ex); } return(_dbContext); }
public UnitOfWork(ILogger logger, IDbContext dbContext) { Logger = logger; _dbContext = dbContext as SpSynthDbContext; }
public UnitOfWork(ILogger logger, IDbContext dbContext) { Logger = logger; _dbContext = dbContext as SpSynthDbContext; }