I have the following abstract class called Sector :
public abstract class Sector { public string ID {get; set;} public string Name {get; set;} public Sector(){} }
And the second class is GICSSector , which inherits from Sector :
public class GICSSector: Sector { public virtual ICollection<GICSIndustryGroup> IndustryGroups {get; set;} }
I have a DbSet in a DbContext :
public DbSet<GICSSector> GICSSectors {get; set;}
I am trying to write a general method for loading data from a CSV file, creating objects on the fly and then storing objects in my SQLLite database:
public static void UpdateEntitiesFromCSV<T>(MyContextFactory factory, string fileName) where T : class { var entities = new List<T>();
I use the free API for managing tables:
protected override void OnModelCreating(ModelBuilder modelBuilder) {
If I run the code, I get the following exception: SQLite Error 1: "there is no such table: sector" .
If I check the type with typeof(T) or using myEntity.GetType() , I get the same expected result: MyNamespace.GICSSector
Why does EF Core want to save it in a table called "Sectors" (the base type), and not in the expected GICSSectors?
How can i fix this?
Note. The method is a general one that will not be used to process only classes that inherit from the Sector .