Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top