Question

I have looked around stackoverflow and search the internet but did not find a answer.

If i try to Enable-Migrations for my project i get the Exception

Error while searching for context type (specify -Verbose to see exception details). Edit the generated Configuration class to specify the context to enable migrations for.

So my question is:

What are the requirements for my project / DbContext in order to let the Entity Framework Migrations find my DbContext WITHOUT specifying it manually ?

Thanks in advance!

Was it helpful?

Solution

You project will need a database class which derive from DbContext, and in your web.config/app.config, you will need a connection string which points to the right database which is used by your database class.

The project you run the command on will need a configuration file to have the right connection string. Even it's class library, you still need this configuration.

OTHER TIPS

I have had a similar issue which was related to the wrong version of Entity Framework being referenced.

You can try executing Update-Package EntityFramework from the Package Manager Console in Visual Studio.

If that does not help then just manually reference the EF 4.3 library from your project and then re-run the Enable-Migrations -force for your project(s).

Cheers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top