I am trying to learn .Net core.
I have 2 to projects :
- .Net Core Web api project
- DLL .NetCore project contains my Unit of Work (entity framework)
My Questions:
How I can pass connection string from appsettings.json to my DLL
I have in startup.cs configuration but I don t how to use it to access to my appsettings.json
public Startup(IConfiguration configuration) { Configuration = configuration; }
there is services.AddDbContext in startup.cs
services.AddDbContext(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection")))
but I don't want to use services.AddDbContext because is a couple to entity framework and if I have to change to other ORM I have to change this code also.
other question how have a responsibility to decrypt the connection string.
a : webapi has to decrypt to the connection string and pass to DLL (unit of work)
b: or unit of work has to decrypt the connection string
in the case I have another project (ie desktop application) how to use DLL (unit of work) do I have to put also the connection string inside my appsettings of the desktop application? (it like kind of repetition ? )