How can I connect to ASP.NET Core's WebApplication.db database?

.net-core entity-framework-core


I'm experimenting with ASP.NET Core and have created a new Web Application (MVC) site with it:

git init CoreWebApp
cd CoreWebApp
dotnet new -t web
dotnet restore

After the code is bootstrapped I ran the initial EF migration

dotnet ef database update

At this point a database is generated at ./bin/Debug/netcoreapp1.0/WebApplication.db and the site runs and allows users to be registered and login successfully. I'd like to connect to that database via SSMS, LINQPad, or another standard SQL Client, but am having troubles. The "open file" prompts typically look for a .mdf extension and complain about the .db file.

How do I connect to an ASP.NET Core, EF Generated WebApplication.db file from a SQL Client?

11/14/2016 5:18:24 PM

Accepted Answer

The dotnet new command is created with portability in mind so it can also run on non-Windows systems. Since there is no SQLExpress for Linux and Mac, the template is created with SQLite as database.

So you need an SQLite client to open it.

Of course you're free to replace with any provider which supports EntityFramework Core, like SQLServer.

Just replace

"Microsoft.EntityFrameworkCore.Sqlite": "1.0.1",

in your project.json with

"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",


services.AddDbContext<ApplicationDbContext>(options =>


services.AddDbContext<ApplicationDbContext>(options =>

in Startup.cs and finally the connection string in appsettings.json

"ConnectionStrings": {
  "DefaultConnection": "Data Source=WebApplication.db"

with the

"ConnectionStrings": {
  "DefaultConnection": "Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;"
11/14/2016 5:47:37 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow