public DbContextOptionsBuilder Extend( DbContextOptionsBuilder optionsBuilder, IDatabaseConnectionStringFactory connectionStringFactory, string assemblyName) { return(optionsBuilder.UseMySql( connectionStringFactory.Create(), sqlOptions => { sqlOptions.MigrationsAssembly(assemblyName); sqlOptions.ServerVersion( new Version( _options.Major, _options.Minor, _options.Build), ServerType.MySql); sqlOptions.EnableRetryOnFailure( 15, TimeSpan.FromSeconds(30), null); }) .EnableSensitiveDataLogging()); }
public ApplicationDbContext CreateDbContext(string[] args) { var migrationAssembly = typeof(ContextFactoryForApplicationDb).GetTypeInfo().Assembly; var dbContextOptionBuilder = _extendOptionsBuilder.Extend( new DbContextOptionsBuilder <ApplicationDbContext>(), _dbConnectionStringFactory.Create(), migrationAssembly.GetName().Name); return((ApplicationDbContext)Activator.CreateInstance( typeof(ApplicationDbContext), dbContextOptionBuilder.Options)); }
public PersistedGrantDbContext CreateDbContext(string[] args) { var migrationAssembly = typeof(ContextFactoryForPersistedGrantDb).GetTypeInfo().Assembly; var dbContextOptionBuilder = _extendOptionsBuilder.Extend( new DbContextOptionsBuilder <PersistedGrantDbContext>(), _dbConnectionStringFactory.Create(), migrationAssembly.GetName().Name); return((PersistedGrantDbContext)Activator.CreateInstance( typeof(PersistedGrantDbContext), dbContextOptionBuilder.Options, new OperationalStoreOptions())); }
public DbContextOptionsBuilder Extend(DbContextOptionsBuilder optionsBuilder, IDatabaseConnectionStringFactory connectionStringFactory, string assemblyName) { return(optionsBuilder.UseSqlServer( connectionStringFactory.Create(), sqlOptions => { sqlOptions.MigrationsAssembly(assemblyName); /*sqlOptions.EnableRetryOnFailure( * maxRetryCount: 15, * maxRetryDelay: TimeSpan.FromSeconds(30), * errorNumbersToAdd: null);*/ }) .EnableSensitiveDataLogging()); }
public TDbConext CreateDbContext(string[] args) { var migrationAssembly = Assembly.GetEntryAssembly(); var dbContextOptionBuilder = ExtendOptionsBuilder.Extend( new DbContextOptionsBuilder <TDbConext>(), DbConnectionStringFactory.Create(), migrationAssembly.GetName().Name); if (SetOptions() == null) { return((TDbConext)Activator.CreateInstance( typeof(TDbConext), dbContextOptionBuilder.Options)); } return((TDbConext)Activator.CreateInstance( typeof(TDbConext), dbContextOptionBuilder.Options, SetOptions())); }