The Meta package Microsoft.AspNetCore.All
contains Entity Framework Core 2, including all required packages for working with Microsoft SQL Server and SQLite.
Note
Note that if you need to work with other databases such as MySQL, you have to download additional packages from NuGet. You can find a list of all currently available Entity Framework Core 2 NuGet packages here: https://www.nuget.org/packages?page=2&q=Tags%3A%22entity-framework-core%22.
To open a session to the database and query and update instances of your entities, you use a DbContext
, which is based on a combination of the unit of work and repository patterns.
Let's see how to prepare the Tic-Tac-Toe application to use Entity Framework Core 2 to connect to an SQL Database by using a DbContext
and a connection string:
- Go to the
Solution Explorer
, add a new folder calledData
, add a new class calledGameDbContext.cs
, and implement aDbSet
property for each Model...