OpenIdConnectProtocolException when I have changed primary key in EntityFramework Core #108
Unanswered
maihuuthai
asked this question in
IdentityServer
Replies: 1 comment 1 reply
-
Unfortunately IdentityServer 4 is out of support. It has a lot of security vulnerabilities that will not be fixed. We recommend to upgrade to Duende IdentityServer 7 as soon as possible. Having said that: it's not possible to change the DbContext like that without changing the code that uses it. You'll have to dig into the code that uses this entity and modify/override it to make it work with the new model. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
IdentityServer version
4
.NET version
.NET 6
Description
All things work well before.
When I received a request to change the Primary Key column from one field to another in the table, I made the change using an Entity Framework Core command. However, the problem occurred when I restarted my project
Reproduction steps
Model previously
[MaxLength(200)] public string UserId {get;set;} //this is primary key ....... other fields here
DbContext previously
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity<entity_name_here>(x => { x.HasKey(y => y.UserId }); }
And then somethings have been changed
Model
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id {get;set;} [MaxLength(200)] public string UserId {get;set;} //this is primary key ....... other fields here
DbContext
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity<entity_name_here>(x => { x.HasKey(y => y.Id }); }
===== Command dotnet ef migrations add .... has been used ===== successfully, database has been changed.
But, when I started the project that throws an exception as below
Expected behavior
Not throw exceptions.
Logs
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions