Entity framework code first creates “discriminator” column

后端 未结 3 1758
情话喂你
情话喂你 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:47

    For completeness, if you want to use the fluent API to stop the inheriting class from being mapped with entity (and therefore stopping the discriminator column being created) you can do the following:

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Ignore();
    }
    

提交回复
热议问题