Given the situation that I have a .NET Core 2.0 Application I also have a Web assembly, a Business assembly, and a DataAccess assembly.
I don\'t want the Web assembl
In order to prevent your DataAccess layer to be visible from a web layer, you should put PrivateAssets element inside a .csproj file of your business layer. Like in a code below.
<ItemGroup>
<ProjectReference Include="..\GiveAway.Data\GiveAway.Data.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
</ItemGroup>
Here you can read more information about PrivateAssets element: https://docs.microsoft.com/en-us/dotnet/core/tools/csproj
This is why you use interfaces, not concrete objects for injection. You shouldn't be leaking references to DBContext outside of your DataAccess assembly. This means you have too much coupling to the underlying database in the higher layers.