0

I had a class:

public class A { }

Now, I change it to abstract and create two implementations:

public abstract class A { }

public class First : A { }

public class Second : A { }

EF 6 completed the update and created the Discriminator column. But if there was existing data in table, the Discriminator value is not set.

How can I update/set Discriminator value for already existing data with EF 6 Code First?

  • Usually, a delete and recreation is needed to properly sync newly complex `EF Core` models with the Database entities. Did you try a [migration](https://www.entityframeworktutorial.net/efcore/entity-framework-core-migration.aspx) in your case ? – Codingwiz Jan 24 '23 at 16:07
  • No. I have automigrations. Possibily I wouldn't delete and recreate the database when changing TPT to TPH – finife1670 Jan 24 '23 at 16:22

0 Answers0