My project structure is pretty standard:
within EFData
.
EFData
is an Entity Framework Core class library that isolates all of the database interaction. Database models, and my DBContext
. I built it that way so that it's database environment agnostic.
The API project of course has a reference to EFData
.
How do I pass the connection string from Startup.cs
in API
to DBContext.cs
in EFData
?
I've read multiple articles that reference a set up different than mine where I might expect a Startup.cs
in my EFData
project. I don't have that.
Within Startup.cs
, I do have what I thought was the required line -
services.AddDbContext<DBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
But EFData
knows nothing about that connection string.