user393014
user393014

Reputation: 475

EF code migration in reference dll coming through nuget

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?

Upvotes: 2

Views: 395

Answers (1)

undefined
undefined

Reputation: 34269

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

Upvotes: 2

Related Questions