Trying to use migrations in a project other then the startup project results in error


Question

Hi I am trying to take advantage of Entity Framework migrations but when I add this command:

PM> Add-Migration

cmdlet Add-Migration at command pipeline position 1

Supply values for the following parameters:

Name: CodeArtMigration

I get back this error message:

Cannot determine a valid start-up project. Using project 'CodeArt.DataAccess' instead. Your configuration file and working directory may not be set as expected. Use the -StartUpProjectName parameter to set one explicitly. Use the -Verbose switch for more information. No packages installed. The EntityFramework package is not installed on project 'CodeArt.DataAccess'.

The last part of the message that says that Entity Framework is not available in he current project is not true because I do have a reference to Entity Framework.

The package source is set to Microsoft and .NET but I als My code is structured in 3 layers I wanted to add the migration data in my DataAccess layer.Also I wanted to minimize thereference to Entity Framework only in my data access layer.

Popular Answer

Make sure that your Package Manager Console has the right project selected in the drop down labeled "Default project:" to the upper right of Package Manager Console window in Visual Studio.

Here's where to find it in Visual Studio 2015:
enter image description here





Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why