mmacneil / AngularASPNETCoreOAuth

Sample project demonstrating user authentication and identity with Angular, Asp.Net Core and IdentityServer4
https://fullstackmark.com/post/21/user-authentication-and-identity-with-angular-aspnet-core-and-identityserver
MIT License
353 stars 232 forks source link

PersistedGrantDbContext issue #14

Open sanpunind opened 4 years ago

sanpunind commented 4 years ago

following command doesn't create respective entities into database , also I don't see consent page after login ,

AuthServer.Infrastructure> dotnet ef database update --context PersistedGrantDbContext

Please suggest

mmacneil commented 4 years ago

Do you receive an exception when running this?

GothicSecret commented 3 years ago

The same issue with standalone SQL Server. I have changed appsettings connection string (CS). But it is still present for second migration. Fix the next lines with the correct CS: public PersistedGrantDbContext CreateDbContext(string[] args) { var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlServer("Server=(localdb)\mssqllocaldb;Database=AuthServer;Trusted_Connection=True;MultipleActiveResultSets=true", sql => sql.MigrationsAssembly(typeof(PersistedGrantDbContextFactory).GetTypeInfo().Assembly.GetName().Name)); return new PersistedGrantDbContext(optionsBuilder.Options, new OperationalStoreOptions()); }

CelestialArcadia commented 2 years ago

Resolved as so:

This exception occurs because one might not have adjusted their "Connection String" as one did in the two of "appsettings.json". The adjustment made there needs to be done in the connection string in this class.

This is the syntax just in case for those who are still skeptical Server=ServerName;Database=DatabaseName;Trusted_Connection=True;