示例#1
0
        public static void AddIdentityServerOperationalDatabase(this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder builder, IConfiguration configuration)
        {
            string connectionString   = configuration.GetConnectionString("IdentityServerOperational");
            string providerType       = configuration["Database:ProviderType:IdentityServer:Operational"] ?? "sqlite";
            string migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

            switch (providerType.ToLower())
            {
            case "mysql":
            case "mariadb":
                builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), sql => sql.MigrationsAssembly(migrationsAssembly));
                break;

            case "sqlite":
            case "sqlite3":
                builder.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
                break;

            case "sqlserver":
            case "mssql":
                builder.UseSqlServer(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
                break;

            default:
                throw new Exception($"Unknow database provider type: {providerType} - IdentityServer Operational");
            }
        }
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.UseSqlite(@"Data Source=G:\\github\\movingsam\\FreeSqlBuilder\\samples\\AngularGenerator\\fsbuilder.db");
     optionsBuilder.UseLoggerFactory(LoggerFactory);
 }