filmov
tv
ASP.Net Core MVC - Use SQLite With Entity Framework Core

Показать описание
Create a .NET Core 3.1 console application in Visual Studio 2019.
As you might know, ASP.NET is able to support many different types of Database providers. Today, I decided to test the use of SQLite in ASP.NET Core 3.1 with Entity Framework Core. For a quick demonstration, I’ll create a simple console application. You can follow along.
Install Entity Framework Core
When working with EF Core, you will want to install the correct package for the Entity Framework Core database provider you want to target in your project. Since this demo project is regarding SQLite, I am going to install the EF Core that supports SQLite.
Add NuGet package reference
Install-Package Microsoft.EntityFrameworkCore.Sqlite
Create DBContext
DbSet which is used to create the Employees table.
OnConfiguring() method is used for configuring the DBContext. Here the option is set to use Sqlite database and also setting a connection string or data source to connect.
we’ll need to run migration using the following commands in Package Manager Console.
Add-Migration InitialCreate
Update-Database
we’ll need to add Microsoft.EntityFrameworkCore.Tools to allow us to create and apply migration.
.net sqlite
.net sqlite tutorial
sqlite .net core
#AspDotNetCore #aspDotNet #Sqlite
#EntityFrameworkCore
As you might know, ASP.NET is able to support many different types of Database providers. Today, I decided to test the use of SQLite in ASP.NET Core 3.1 with Entity Framework Core. For a quick demonstration, I’ll create a simple console application. You can follow along.
Install Entity Framework Core
When working with EF Core, you will want to install the correct package for the Entity Framework Core database provider you want to target in your project. Since this demo project is regarding SQLite, I am going to install the EF Core that supports SQLite.
Add NuGet package reference
Install-Package Microsoft.EntityFrameworkCore.Sqlite
Create DBContext
DbSet which is used to create the Employees table.
OnConfiguring() method is used for configuring the DBContext. Here the option is set to use Sqlite database and also setting a connection string or data source to connect.
we’ll need to run migration using the following commands in Package Manager Console.
Add-Migration InitialCreate
Update-Database
we’ll need to add Microsoft.EntityFrameworkCore.Tools to allow us to create and apply migration.
.net sqlite
.net sqlite tutorial
sqlite .net core
#AspDotNetCore #aspDotNet #Sqlite
#EntityFrameworkCore
Комментарии