문제

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!

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top