问题
I have to update and change Discriminator(_Disc_) field of a table while mapped entities doesn't have it as an entity member. any solution?
回答1:
Discriminator column is used to define type of entity in TPH inheritance and EF cannot change it - never. It is like inheritance in any object oriented language - once you define object of some type you cannot make it different type - you can only cast it to parent but it will still be instance of original type. The only way to change it to different type is to create a new instance of the new type and somehow copy values from the first object to the new one.
So if you need to change discriminator you must do it without EF = by using old ADO.NET and SQL but if your change will not follow other rules in your entity model you will break EF functionality and your application will not work.
来源:https://stackoverflow.com/questions/8668678/how-can-i-change-discriminator-disc-field-while-it-is-used-as-a-condition