Downcasting with Entity Framework

后端 未结 2 521
醉梦人生
醉梦人生 2020-12-11 23:19

I have a project where I\'ve defined in EF an Employer as a derived class of User. In my process I create a user without knowing whether it will e

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 00:02

    Supose that your Employer entity has only nullable properties then it is possible to go to the table at the database and change the Discriminator from User to Employer. All relationships will be kept. And also it is possible to do the opposite.

提交回复
热议问题