Entity Framework Core (EF Core) is a lightweight, extensible, cross-platform object-relational mapper for .NET. It lets an ASP.NET Core web API work with relational database data through C# objects and ORM techniques instead of hand-written SQL queries. section 4.0 section 4.3
A practical EF Core setup for a web API follows these steps:
- Choose a DBMS, such as a local Microsoft SQL Server Express instance or a cloud-hosted service. section 4.0 section 4.5
- Define entity classes that represent database tables and support CRUD operations from application code. section 4.5
- Create an ApplicationDbContext to represent the operational connection between ASP.NET Core and the database. section 4.5
- Configure the context with a connection string, storing development secrets through Visual Studio Secret Manager. section 4.5
- Use EF Core migrations to generate the database structure from the current data model. section 4.5
Applying EF Core to a board-game API
Replace the MyBGList web API's on-demand fake data with a DBMS-backed data source. Use ApplicationDbContext and entity classes to perform create, read, update, and delete operations; express those operations with LINQ and IQueryable<T> rather than requiring specific SQL knowledge. section 4.0 section 5.0
EF Core supports both database-first development, which generates a data model from an existing schema, and code-first development, which generates a schema from a manually created model. ORM usage can improve security, flexibility, optimization, readability, and maintainability, although raw SQL may still have drawbacks to weigh. section 4.0 section 4.5



