EF code migration in reference dll coming through nuget

谁说胖子不能爱 提交于 2019-12-12 19:13:14

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/18391449/ef-code-migration-in-reference-dll-coming-through-nuget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!