2017-09-05 126 views
2

我從.NET Core 1.1升級到.NET Core 2.0並遇到以下問題(我也升級了一些庫以支持.net core 2.0)IdentityServer4升級到.NET Core 2.0(AddConfigurationStore,AddOperationalStore)的問題

CS1929「ConfigurationStoreOptions」不包含關於「UseNpgsql」和最好的擴展方法過載的定義「NpgsqlDbContextOptionsExtensions.UseNpgsql(DbContextOptionsBuilder,串,動作)」要求式「DbContextOptionsBuilder」

Startup.cs

的接收機
 services.AddIdentityServer() 
      .AddSigningCredential(Certificate.Get()) 
      .AddAspNetIdentity<User>() 
      .AddConfigurationStore(builder => 
       builder.UseNpgsql(connectionString, options => 
        options.MigrationsAssembly(migrationsAssembly))) 
      .AddOperationalStore(builder => 
       builder.UseNpgsql(connectionString, options => 
        options.MigrationsAssembly(migrationsAssembly))); 
使用UseSqlServer

同樣的問題

// configure identity server with in-memory users, but EF stores for clients and resources 
services.AddIdentityServer() 
    .AddTemporarySigningCredential() 
    .AddTestUsers(Config.GetUsers()) 
    .AddConfigurationStore(builder => 
     builder.UseSqlServer(connectionString, options => 
      options.MigrationsAssembly(migrationsAssembly))) 
    .AddOperationalStore(builder => 
     builder.UseSqlServer(connectionString, options => 
      options.MigrationsAssembly(migrationsAssembly))); 

http://docs.identityserver.io/en/release/quickstarts/8_entity_framework.html

注:我已經加入 「使用Microsoft.EntityFrameworkCore;」

+0

2.0.0 RC1剛剛發佈的NuGet該目標netstandard 2.0 –

回答

5

解決方案:

 services.AddIdentityServer() 
      .AddSigningCredential(Certificate.Get()) 
      .AddAspNetIdentity<User>() 
      .AddConfigurationStore(options => 
      { 
       options.ConfigureDbContext = builder => 
        builder.UseNpgsql(connectionString, 
         sql => sql.MigrationsAssembly(migrationsAssembly)); 
      }) 
      // this adds the operational data from DB (codes, tokens, consents) 
      .AddOperationalStore(options => 
      { 
       options.ConfigureDbContext = builder => 
        builder.UseNpgsql(connectionString, 
         sql => sql.MigrationsAssembly(migrationsAssembly)); 

       // this enables automatic token cleanup. this is optional. 
       options.EnableTokenCleanup = true; 
       options.TokenCleanupInterval = 30; 
      }); 
1

自己剛剛遇到同樣的問題。在IndentityServer4.EntityFramework github上的拖網透露使得利用ConfigureDBContext屬性的示例Startup.cs