Unable to delete record from a core table When there is an equal view using Entity Framework C#
I use entity framework in Asp.net c# project.
There is a table in the DB called ‘Sales’
There is a view called ‘HotSales’
The view contains only the hot sales from the ‘Sales’ table + more info from another table using JOIN.
In the DbContext class I have a DbSet object for each of them.
I try to delete a record from the ‘Sales’ table this way:
Sale sale = _context.Sales.FindAsync(id); _context.Sales.Remove(sale as Sale); _context.SaveChanges();
I receive an error about ‘HotSales’ type:
“The entity type ‘HotSales’ is not mapped to a table, therefore the entities cannot be
persisted to the database. Call ‘ToTable’ in ‘OnModelCreating’ to map it to a table.”
Why the entity framework recognizes the Sales object as HotSales?
How can I delete the record?