Sunday, 10 March 2024

Using Sqlite database with EF Core

 Sqlite is simple file based database; you just need to add reference of below packages in your API project and need to configure path to DB file.

Microsoft.EntityFrameworkCore

Microsoft.EntityFrameworkCore.Design

Microsoft.EntityFrameworkCore.Sqlite

Microsoft.EntityFrameworkCore.Tools














Once you will create DBContext, you need to create migration and need to update database, below are CLI commands for the same.

1. dotnet ef migrations add Name_Of_Migration

2. dotnet ef database update

Note: No need to create sqlite db file separately once we will update database with migration it will automatically create DB file.





No comments:

Post a Comment

How to create and use middleware in asp.net core

Middleware is piece of code that's assembled into an app pipeline to handle requests and responses.  Each middleware component in the re...