You might have encountered this type of question before but in my case, it's a bit different scenario and I cannot find a feasible answer. (It might exist already, however I was not able to find one).
I'm working on a business application which has the entire functionality split into multiple class libraries. I'm using Entity Framework and I'm not sure which is the right place to include it? In my case, I've these libraries:
In order to make this work, I've to install Entity Framework in every library separately. Eventually they will be included in a number of ASP.NET MVC Web Applications. I'd have installed Entity Framework directly into the web apps but this application will have mobile apps in the future along with a possible windows store app. In that case, I can simply set up a ASP.NET Web API and use the existing class libraries to generate the required data. This is the only factor holding me back from incorporating Entity Framework directly into the web apps.
So what's your opinion on this? Include Entity Framework in every library separately (required to function properly) or simply include in the web app and later follow the same approach for the Web API?
Thank you.
You only need to "install" EntityFramework into one place: Project.Library.Models. Assuming standard code-first objects as your DTOs, you won't need a direct reference anywhere else as long as you wrap the context object with a Data Access Layer.
Adding a reference to that assembly will cause the requisite DLLs to be included with your apps, web sites, etc. Note that if you are using EntityFramework.SqlServer, the transient dependency won't be detected by Visual Studio so you need to do something like:
class Include
{
private Include() { }
private SqlProviderServices IncludeSql;
}
Somewhere in the models project so that DLL is copied over also.