Entity Framework: How to avoid Discriminator column from table?

前端 未结 7 1841
无人及你
无人及你 2020-12-08 07:10

I have the following table created using Entity Framework Code First approach.

  1. How do I modify the C# code so that the unwanted Discriminato
7条回答
  •  情话喂你
    2020-12-08 07:42

    Since both "GiftCouponPayment" and "ClubCardPayment" derives from "PaymentComponent" EF will not use separate tables and will need that column. If you want a different behaviour you would have to override the default table access and map the fields to your classes (which I think you don't want to do) Not sure if there is an easy way to to this. From entity first, I know that there is a way through the template which creates the tables.
    The same is for the foreign key column name. EF uses that way of creating the name for key/foreignkey names. If you want to format the table as you like, you have to do it all yourself, which leads to the question why use EF then at all.
    Is there a particular reason why you want to do that, other than cosmetics?

提交回复
热议问题