Relative Content

Tag Archive for .net-coreentity-framework-core

.NET 8 EF is setting discriminator to the wrong value in the IdentityUserRole table

I’ve customized Identity and using Code First scaffolded the Identity tables in a .NET 8 Web API. The problem I’m having is EF is putting in a value of “IdentityUserRole” in the Discriminator column. However, when I query the ApplicationUserRole table or use UserManager to get the user’s roles, it is not returning any results because it’s adding ‘ApplicationUserRole’ to it’s SQL Server query. If I update all the values in the ApplicationUserRole Discriminator column everything works fine except I can’t stop EF from adding “IdentityUserRole” in the Discriminator column when I add a user to a role. Any idea on how I’ve misconfigured Identity? I’ve done this plenty in .NET 6 and 7 with no issues.