I was just practicing code first new database entity framework from msdn, I wanna know whether a table without primary key can be created in code first new database EF?
Starting with .NET Core 2.1, EF Core supports models without primary key.
This is realized through a concept of Query Types instead of Enitity Types.
See https://docs.microsoft.com/en-us/ef/core/modeling/query-types
Some of the main usage scenarios for query types are:
- Serving as the return type for ad hoc FromSql() queries.
- Mapping to database views.
- Mapping to tables that do not have a primary key defined.
- Mapping to queries defined in the model.
Query Types have limits though. They cannot be inserted, updated or deleted on the database. And they have only limited support of navigation properties.