2

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?

undefined
  • 33,537
  • 22
  • 129
  • 198
user393014
  • 445
  • 1
  • 8
  • 15

1 Answers1

2

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

undefined
  • 33,537
  • 22
  • 129
  • 198
  • I know the dependency thing but i don't think you understand the issue i described, when you open package manger console and run update-database if you don't provide the project name with parameter then it will take the default project selected in Package manager console, so its throwing error get-project failed – user393014 Aug 23 '13 at 01:28
  • The Update-Database command is included in powershell that gets imported with the EF nuget package. This means unless you have this included in your solution it wont be available in the package manager console. – undefined Aug 23 '13 at 01:34
  • @user393014 which version of EF are you installing? – undefined Aug 23 '13 at 08:17