How to use EF Core query types in ASP.NET Core 7
Entity Framework Core (EF Core for short) is a popular ORM (object-relational mapper) from Microsoft that allow you to perform CRUD operations (create, read, update, and delete) without having to know how the data is persisted in the underlying database.
When working with ORMs, we often leverage models that are mapped to database tables. However, what if we have a model that doesn’t mimic a database table? How can we map non-entity types and populate objects of such a model in our applications? We can accomplish this with query types.
Initially introduced in EF Core 2.1, query types are non-entity types (classes) that can map to tables or views in the database without an identity column specified, meaning tables and views that lack a key. EF Core query types make it simpler to query views and model types that don’t require identity columns. However, because query types don’t have an identity column defined, you cannot insert, update, or delete data using them. You can use them only to retrieve the data.
