参考文件中的EF代码迁移通过nuget进行 [英] EF code migration in reference dll coming through nuget
问题描述
现在情况是让我们说 ProductA 正在使用具有启用迁移功能的xyz.dll的软件包。现在,ProductA的开发者想要首先使用该xyz.dll迁移来升级由Framework EF代码创建的数据库,但是这个dll只是被添加为引用的dll。所以在包管理器控制台(如Update-Database)中运行命令不起作用,因为项目不在当前的解决方案中,而在参考文件dll中
我该如何解决? p>
这实际上很容易解决,你添加nuget包的项目也需要引用EF。
您可以在您的nuget包中实际执行此功能,例如:
<依赖关系>
< dependency id =EntityFrameworkversion =4.2.0.0/>
< / dependencies>
在您的nuspec(显然更新版本与您正在使用的)
请参阅: http://docs.nuget。 org / docs / reference / nuspec-reference#指定依赖关系
和
http://docs.nuget.org/docs/reference/versioning#Specifying_Version_Ranges_in_.nuspec_Files
有关依赖语法如何工作的一些更多细节
We have a situation. Our company has Framework build on .net which is used by products developed using that Framework. Now this Framework is using EF code first. We want to implement EF Code Migration though generated migrations definitions because our entities are there in one of the Framework project. So I have implemented it. But the situation is this Framework we are distributing to other products as Nuget package (internal).
Now the situation is lets say ProductA is consuming the package which has xyz.dll which has migrations enabled in it. Now the developers of "ProductA" wants to upgrade the database created by Framework EF code first using that xyz.dll migrations, but this dll is only added as referenced dll. So running command in package manager console like Update-Database is not working because project is not in the current solution and its in reference dll
How do I solve this?
This is actually pretty easy to solve, the project which you add your nuget package to also needs to reference EF.
You can actually enforce this inside your nuget packages with a dependency eg:
<dependencies>
<dependency id="EntityFramework" version="4.2.0.0" />
</dependencies>
in your nuspec (obviously update the version with the one you are using)
See: http://docs.nuget.org/docs/reference/nuspec-reference#Specifying_Dependencies
and
http://docs.nuget.org/docs/reference/versioning#Specifying_Version_Ranges_in_.nuspec_Files
for some more details around how the dependancy syntax works
这篇关于参考文件中的EF代码迁移通过nuget进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!