Reputation: 15101
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.
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.
Upvotes: 3
Views: 3122
Reputation: 4024
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"
Upvotes: 3