private Microsoft.EntityFrameworkCore.DbContextOptions GetDbContextOptions()
        {
            var b = new Microsoft.EntityFrameworkCore.DbContextOptionsBuilder();

            b.UseMySql("server=35.197.80.226;Database=Converter;Uid=root;Pwd=P@ssw0rd");
            return(b.Options);
        }
Example #2
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");
            }
        }
        /// <summary>
        /// 重写的OnConfiguring方法
        /// </summary>
        /// <param name="optionsBuilder"></param>
        protected override void OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

            MySqlConfig useConfig = ConfigPacker.GetConfigPacker().GetConfig <MySqlConfig>();

            optionsBuilder.UseMySql(useConfig.Connectstr);
        }
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder.UseMySql(new FakeDbConnection("A=B"));