Entity Framework
From MgmtWiki
Full Title
This wiki page is about the Microsoft ORM called Entity Framework including best practices and troubleshooting on ASP.NET.
Context
The context is a ASP.NET Core package version 5 or up that is deployed as a complete package.
Problems
Entity Framework assumes a configuration which makes it easy to get running, but hard to adapt to other environments.
Troubleshooting
- The entity type 'Access' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()' is an error that occurs if a POCO class is used in a Dataset table that does not designed to be a db table in its own right. The answer is to mark the POCO class with an [owned] annotation.
- Annotation of a foreign key is described in the blog Data Annotations - ForeignKey Attribute in EF 6 & EF Core.