--- no-loc: [Home, Privacy, Kestrel, appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] --- ::: moniker range=">= aspnetcore-3.0" Create a *Data* folder. Add the following `MvcMovieContext` class to the *Data* folder: [!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie3/zDocOnly/MvcMovieContext.cs?name=snippet)] The preceding code creates a `DbSet` property for the entity set. In Entity Framework terminology, an entity set typically corresponds to a database table, and an entity corresponds to a row in the table. ### Add a database connection string Add a connection string to the *appsettings.json* file: [!code-json[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie3/appsettings_SQLite.json?highlight=10-12)] ### Add NuGet packages and EF tools [!INCLUDE[](~/includes/add-EF-NuGet-SQLite-CLI.md)] ### Register the database context Add the following `using` statements at the top of *Startup.cs*: ```csharp using MvcMovie.Data; using Microsoft.EntityFrameworkCore; ``` Register the database context with the [dependency injection](xref:fundamentals/dependency-injection) container in `Startup.ConfigureServices`. [!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie3/Startup.cs?name=snippet_UseSqlite&highlight=6-7)] Build the project as a check for compiler errors. ::: moniker-end ::: moniker range="< aspnetcore-3.0" Add the following `MvcMovieContext` class to the *Models* folder: [!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie22/Data/MvcMovieContext.cs)] The preceding code creates a `DbSet` property for the entity set. In Entity Framework terminology, an entity set typically corresponds to a database table, and an entity corresponds to a row in the table. ### Add a database connection string Add a connection string to the *appsettings.json* file: [!code-json[](~/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/appsettings_SQLite.json?highlight=8-10)] ### Add required NuGet packages Run the following .NET Core CLI command to add SQLite and CodeGeneration.Design to the project: ```dotnetcli dotnet add package Microsoft.EntityFrameworkCore.SQLite dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design ``` The `Microsoft.VisualStudio.Web.CodeGeneration.Design` package is required for scaffolding. ### Register the database context Add the following `using` statements at the top of *Startup.cs*: ```csharp using MvcMovie.Models; using Microsoft.EntityFrameworkCore; ``` Register the database context with the [dependency injection](xref:fundamentals/dependency-injection) container in `Startup.ConfigureServices`. [!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie22/Startup.cs?name=snippet_UseSqlite&highlight=11-12)] Build the project as a check for errors. ::: moniker-end