I'm new to EF Core and sorry if this is a stupid question. I'm getting the Invalid Column "Discriminator" when I try to query
Context.EmployeeAddressNavigation.where(x =>x.Name.Contains("name")).Select(x => new {x.Id,x.employAddress})
Employee
public class Employee
{
public Guid Id {get;set;}
public string Name {get;set;}
}
EmployeeAddress
public class EmployeeAddress
{
public Guid EmployeeId {get;set;}
public Guid AddressId {get;set;}
}
EmployeeAddressNavigation
public class EmployeeAddressNavigation : Employee
{
public EmpoyeeAddress employAddress {get;set;}
}
I configured onModelCreate like this
override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Employee>().ToTable("employee");
modelBuilder.Entity<EmployeeAddress>().ToTable("employeeaddress");
modelBuilder.Entity<EmployeeAddressNavigation>()
.HasMany(r => r.EmployeeAddress)
.WithOne()
.HasForeignKey(r => r.EmployeeId);
}
I saw similar question here EF Core “Invalid column name 'Discriminator'” error with inheritance but I did not understand how to fix my issue ? Can some one please also explain me how to use HasDiscriminator() and what is it's purpose?