The entity type 'Personal' is part of a hierarchy, but does not have a discriminator value configured

2

I'm trying to generate migrations using the command:

dotnet ef migrations add InitialMigration --context MyContext 

and the same is returning me the following message.

  

System.InvalidOperationException: The entity type 'PersonPass' is part of a hierarchy, but does not have a discriminator value configured.

In my classes I have PessoaFisica and PessoaJuridica inheriting from Pessoa and Funcionario inheriting from PessoaFisica ( public class Funcionario : PessoaFisica ).

modelBuilder.Entity<Funcionario>()
.ToTable("Funcionario");
    
asked by anonymous 08.11.2016 / 18:01

1 answer

0

What is happening, it seems to me, is that by using the TPH (Table Per Hierarchy) method you have to mention the value of the column of discrimination. ex: link

For this, in model builder, you have to do something like:

modelBuilder.Entity<Funcionario>()
    .Map<Funcionario>(m => m.Requires("Descriminator").HasValue("FUNC"))
    
08.11.2016 / 18:22