2017-09-13 125 views
0

我正在使用IdentityServer4。IDbContextFactory該方法或操作未實現

我想使用EF作爲配置數據(教程[第一步] [http://identityserver4.readthedocs.io/en/release/quickstarts/8_entity_framework.html])。

我statup.cs

namespace IdentityServer 
{ 
    public class Startup 
    { 
       { 
      services.AddMvc(); 

      var connectionString = @"Data Source=CR08186\\sqlexpress;Initial Catalog=IdentityServer;Persist Security Info=True;User ID=sa;Password=MsSql2008"; 
      var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name; 

      // 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))); 

     } 
} 

從CMD運行dotnet ef migrations add InitialIdentityServerMigration -c PersistedGrantDbContextdotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb

,並有一個錯誤

An error occurred while calling method 'ConfigureServices' on startup class 'Startup'. Consider using IDbContextFactory to override the initialization of the DbContext at design-time. Error: The method or operation is not implemented. No DbContext named 'PersistedGrantDbContext' was found.

任何幫助,將不勝感激!

回答

0

所以,問題出在使用的數據庫。連接sting containg數據庫,已經存在。 如果選擇新的數據庫(現在不存在),一切都會正常工作。

相關問題