mmacneil / AngularASPNETCoreOAuth

Sample project demonstrating user authentication and identity with Angular, Asp.Net Core and IdentityServer4

Home Page:https://fullstackmark.com/post/21/user-authentication-and-identity-with-angular-aspnet-core-and-identityserver

Repository from Github https://github.commmacneil/AngularASPNETCoreOAuthRepository from Github https://github.commmacneil/AngularASPNETCoreOAuth

PersistedGrantDbContext issue

sanpunind opened this issue · comments

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

Do you receive an exception when running this?

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());
}

commented

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;