Extending Entity Framework Model to include new property

后端 未结 3 1070
攒了一身酷
攒了一身酷 2020-12-16 04:04

I\'m new to EF so please excuse me if this is a noob question.

Basically, we have a EF model set up using Model First for our \'platform\' project and is shared acro

3条回答
  •  被撕碎了的回忆
    2020-12-16 04:25

    You cannot use inheritance because once entity is loaded from the data source EF will not know about inheritance and because of that it will instantiate base type without your properties instead of derived type with your properties. Any inheritance must be mapped in EDMX if EF have to work with it.

    Using partial class will solve your problem but:

    • All parts of partial class must be defined in the same assembly
    • Properties from your partial part are not persisted to the database
    • Properties from your partial part cannot be used in linq-to-entities queries

提交回复
热议问题