Isn't there a more graceful way to have Entity Framework deployed with your UI project (specifically the sql server driver for EF: EntityFramework.SqlServer.dll) deployed with your asp.net project than having to add reference to EF via NuGet in your UI project?
In this stack overflow question, the answer posted is to make an unneeded line of code in my asp.net project just to get the dependent file to copy over when my asp.net app is deployed:
stack overflow article
I don't think I should have to add unused code in order to deploy a dependency.
Nor should I have to add a reference to EF in my UI project.
I understand that the EF file (EntityFramework.SqlServer.dll) is injected at run time into entity framework.
Yes - my asp.net project is configured correctly - it runs great if it has a nuget reference to EF or the dll EntityFramework.SqlServer.dll.
But:
I don't want to add a reference to entity framework using nuget to my asp.net mvc project just to deploy this file.
I don't want to add a reference to the file, which is in my DAL project bin folder, that would be very brittle.
I could add a post build event to the asp.net mvc project, but that seems brittle too.
In MSTest projects we can add a [DeploymentItem ...] attribute to deploy these types of dependencies. Is there an equivalent in asp.net, perhaps something you can put in the web.config.
I would think that if I could configure in the web.config to reference the sql provider used by entity framework:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
That you could also configure the dll to deploy too!
2/13 Edit
I am using visual studio 2013 and EF 6.
A couple of people have asked why I care and why I don't just use NuGet to manage this and add the entity framework reference to my UI project using NuGet.
2 Reasons:
My UI should not have to know anything about what my ORM is! And should not need a project reference to it in my UI project.
More importantly, I manage a team of developers with varying skill levels, onshore and off shore. I don't want one of them to accidentally use an EF class in the UI. Having a reference to EF in the UI project makes it all to easy to have VS or Resharper slip in a "using System.Data.Entity;" and off you go using your ORM in your UI project.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…