In my aspnetcore app (v2.1) I need to configure a read-only database (entityframework core + SQLite) which is in ~/wwwroot/App_Data/quranx.db
I need to call this code in Startup.ConfigureServices
services.AddDbContext<QuranXDataContext>(options => options
.UseSqlite($"Data Source={databasePath}")
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
);
But at that point I cannot find a way to get the path to wwwroot. To get that path I need IHostingEnvironment
, but I am unable to get a reference to that until Startup.Configure
is called, and that is after Startup.ConfigureServices
has finished.
How is this done?
Path.GetFullPath("wwwroot");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With