Joshua
Joshua

Reputation: 61

Using SQLite with ASP.NET Core MVC yields SQL Server error 52 (Unable to locate a Local Database Runtime installation)

At the moment I'm doing the Tutorial "ASP.NET Core Mvc Web App" from Microsoft (Link: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?view=aspnetcore-6.0&tabs=visual-studio).

I'm using Visual Studio Code with the .net version 6.0. I have the following extensions installed:

At the third chapter "model" I'm having some issues.

One of my biggest issue is the database. I need to enter this code:

dotnet ef database update

after some time it shows this error: Error Message:

enter image description here

[...] Unable to locate a Local Database Runtime installation [...]

What can I do? Did I forget something? Is that a proxy issue? I am a beginner. Hope you can help me.

Upvotes: 1

Views: 1084

Answers (1)

CodeCaster
CodeCaster

Reputation: 151720

You're using SQLite, but the tutorial uses SQL Server. The EF Core console app sample uses SQLite though.

Instead of installing Microsoft.EntityFrameworkCore.SqlServer, use:

dotnet add package Microsoft.EntityFrameworkCore.Sqlite

And instead of UseSqlServer(), use:

options.UseSqlite($"Data Source={DbPath}");

Upvotes: 2

Related Questions