From scratch, I made a new solution with two projects: one was MVC 3 and the other a supporting EF 4.2 project. The whole thing builds successfully. From the MVC project I
I had installed EF 6 which added:
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
In my config file. I had other scaffolding issues and so decided to fall back to Ef 5. After uninstalling EF 6 and reinstalling EF 5 I deleted the from the config and then I was able to build my new controller. I discovered this by using the
PM> Update-Database –Verbose
I found thjis helped when I had this problem:
Uninstalled the pre-release version of EF and installed EF5 Went to Sql Server Object Explorer and deleted the db. Rebuilt the solution used PM> Update-Database -Verbose
Perhaps the problem was with pre-release EF or just cleansing the palate was all it needed.
I'm quite new to all of these but this did let me use the Add Controller scaffolding tool with the "MVC controller with read/write actions and reviews, using Entity Framework" template selected.
Rename the Model class - worked for me
Are you sure to have a ConnectionString in your Web.Config file before to create a Controller ? Sometimes we create another project which contains the Entity DB Context and we forgot to add this same connectionString in the Web.Config inside the another project.
<connectionStrings>
<add name="Monsters2Entities" ... />
</connectionStrings>
I managed to solve my problem by changing the edmx's code generation strategy to T4, adding a EF5 Db Context and replacing %edmxInputFile% in both the *.tt and *.Context.tt files.
I face this issue "Unable to retrieve metadata..." while I was dding a Controller. Solution for this is as follows.
It seems this is a bug in MVC. I hope with this you can go ahead.