Where is the Sqlite database saved for asp.net core MVC 2.2?

asp.net-core asp.net-core-2.2 entity-framework-core

Question

I create an asp.net core mvc 2.2 application with

options.UseSqlite("Data Source=test.db")

Important note: VS2017 must be launched with Administrative Privilege, otherwise database cannot be created. It is specific to Asp.net core 2.2, the previous one has no such a problem.

Question

Where is the sqlite database saved? I have searched for but I got nothing.

Note: As a comparison, Asp.net core 2.1 saves the sqlite database in the project folder.

1
2
12/21/2018 8:09:23 PM

Popular Answer

Control where it is stored the easy way

var connString = Configuration.GetConnectionString("MyDB").Replace("~", _env.ContentRootPath);
services.AddDbContext<RemoteHealingTechContext>(options => options.UseSqlite(connString));

Grabbing _env in the constructor

public Startup(IConfiguration configuration, IHostingEnvironment env)
{
    Configuration = configuration;
    _env = env;
}

Then you can use a connection string that looks like this

"DataSource=~\\App_Data\\MyDB.db"
0
3/26/2019 3:03:30 PM


Related Questions





Related

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