I need to create DbSet for my ignored entity. Now I have in my modelBuilder next code:
modelBuilder.Ignore<ExtendedDepartment>();
And inside my DbSet I have:
public DbSet<ExtendedDepartment> ExtendedDepartments { get; set; }
When I`m trying to get data from that Dbset I have error:
InvalidOperationException: Cannot create a DbSet for ExtendedDepartment because this type is not included in the model for the context.
So I am trying to ignore this table in migration, maybe I am doing smthing wrong.
ExtendedDepartmentstable and accessDbSet<ExtendedDepartments >, you should not usemodelBuilder.Ignore<ExtendedDepartment>();. If you real want to ignore the migration, you need to modify the generatedmigration.csfile to remove the code related withExtendedDepartment. In general, there is no need to because if you did not change anyting inExtendedDepartment, it would not generate migration forExtendedDepartmenttable. If you changed, you should keep the table udpate.ExtendedDepartmentis from two tables, there is no need to defineDbSet<ExtendedDepartment>in the DbContext, you could query ExtendedDepartment from the two tables.DbSetbyFromSql. You may consider use Entity Framework Core - Mapping Stored Procedures, Fluently to extend DbContext instead of usingDbSet<T>.