I am using EF CF approach for a website with MySQL.
For some reason EF creates a column in my Post table called “Discriminator” and contains the VARCHAR “Post”.
Why is this column created? Can I do something to avoid it being created? Are there any advantages of having this column?
The
Discriminatorcolumn is used and required in Table-Per-Hierarchy inheritance scenarios. If you for example have a model like this …… and make the
BaseEntitypart of the model, for instance by adding aDbSet<BaseEntity>to your derived context, Entity Framework will map this class hierarchy by default into a single table, but introduce a special column – theDiscriminator– to distinguish between the different types (PostorOtherEntity) stored in this table. This column gets populated with the name of the type (againPostorOtherEntity).