Base solution for your next web application
Open Closed

discriminator column added while extending UserOrganizationUnit #11274


User avatar
0
jtallon created
  • What is your product version? 10.2.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net Core

I'm trying to add a single column (RoleId) to UserOrganizationUnit I've created a class public class OrganizationUnitRole_Extended : UserOrganizationUnit { public virtual Role Role { get; set; } public int RoleId { get; set; } }

I've added it to the dbcontext public virtual DbSet<OrganizationUnitRole_Extended> OrganizationUnitRole_Extended { get; set; }

However my migrations add in a discriminator column.

Is there any way to avoid this? I've read that fluent api could resolve it but I haven't figured out how to do it properly.


3 Answer(s)
  • User Avatar
    0
    jtallon created

    Adding [NotMapped] Public string Discriminator {get; set;} gives the correct migration... but is that ok?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @jtallon

    This is added by EF Core, see https://learn.microsoft.com/en-us/ef/core/modeling/inheritance#table-per-hierarchy-and-discriminator-configuration. I suggest you to not remove it because it will cause problems. You can choose a different name for this column or choose a different extension approach.

  • User Avatar
    0
    jtallon created

    We now inherit from an out of the box class like this and migrations adds Discriminator column and RoleId which makes sense now because when we look at ef query generated with our extended repo it adds this on the query