Failing migration after update to EF Core 8: The object has been removed from the model
After upgrading our application from .net 6 to .net 8 we are able to access the application and interact with the DbContext. However when interacting with DbContext through the dotnet-ef
tool, for example adding a migration, it will always fail with the following error:
.NET 8 EF Core is setting discriminator to the wrong value in the IdentityUserRole table
I’ve customized Identity and using code-first scaffolded the Identity tables in an ASP.NET Core 8 Web API. The problem I’m having is EF Core is putting in a value of IdentityUserRole<string>
in the Discriminator
column.
.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.