I have an entity for which I don't want a table. The entity is used to generate a report and is populated using a SQL query:
public IEnumerable<Entities.MembersReportRow> Get()
{
return _context.MembersReportRows
.FromSqlRaw(@"
SELECT...")
.ToList();
}
Using modelBuilder.Ignore<MembersReportRow>();
stops the code for creating the table from being added to the migration, but then the method above stops working with error:
Cannot create a DbSet for 'MembersReportRow' because this type is not included in the model for the context.
I've also tried:
modelBuilder.
.HasNoKey()
.ToSqlQuery(@"
SELECT...
");
...but the code to create the table still gets created in the migration, which surprises me a little as I'm specifically stating "ToSqlQuery".
Any help would be appreciated!