0

Je travaille avec IdentityServer4.IDbContextFactory La méthode ou l'opération n'est pas implémentée

Je veux utiliser EF pour les données de configuration (1ère étape dans le tutoriel [http://identityserver4.readthedocs.io/en/release/quickstarts/8_entity_framework.html]).

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

     } 
} 

de cmd en cours d'exécution dotnet ef migrations add InitialIdentityServerMigration -c PersistedGrantDbContext et dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb

et ont une erreur

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.

Toute aide serait appréciée!

Répondre

0

Donc, le problème était dans la base de données utilisée. Connexion sting containg base de données, qui existent déjà. Si vous choisissez une nouvelle base de données (n'existe pas maintenant), tout fonctionnera correctement.