Entity framework code first creates “discriminator” column

后端 未结 3 1759
情话喂你
情话喂你 2020-11-30 05:05

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\".

3条回答
  •  没有蜡笔的小新
    2020-11-30 05:54

    You can stop the column being created by adding the [NotMapped] data annotation to the models that are inheriting from your base class. This will tell EF not to add your class to future migrations, removing the discriminator column.

    public class BaseClass
    {
    }
    [NotMapped]
    public class InheritingClass : BaseClass 
    {
    }
    

提交回复
热议问题