I have a MVC 4 project. After successfully adding a Controller (using SPA template) and compiling, I tried to add another controller but on the Add Controller dialog there this message saying "No model classes are available".
I think it happens after I NuGet EF 4.3 (upgrading from 4.1).
do you upgraded EF AFTER having created a DbDataController?
The point is that while in theory one can upgrade or add a Nuget package also on an existing project....in practice this is very likely to create problems, expecially if you use various type of scaffolding.
No, I upgraded the EF first thing after creating the project.
Here are the steps to reproduce:
1. Open Visual Studio 2010 (Professional)
2. Create new project from the template "ASP.NET MVC 4 Web Application"
3. On the "Project Template" dialog select "Single Page Application", use Razor, leave the "Create a unit test project" option unchecked (all default)
4. Open the NuGet "Package Manager Console" and update the Entity Framework (currently to version 4.3.1) by running "Install-Package EntityFramework"
5. Build the project
6. Add a new controller by following the instructions inside the example TodoItem.cs file. Basically, creating a new controller using the Single Page Application template, using the TodoItem as the model class and creating a new data context class. This will
create (among other files) a new controller inheriting from DbDataController.
7. Build the project
8. Try to add a new Controller - the Model class selection drop down box is replaced with a red X icon and a message: "No model classes are available".
The point is that according to your description ACTUALLY there not other classes you can use as models for your DBDataController because you have not added new contexts or new classes to the existing context
sagy
0 Points
8 Posts
Can't create new controller, "No model classes are available"
Apr 11, 2012 11:51 AM|LINK
Hi,
I have a MVC 4 project. After successfully adding a Controller (using SPA template) and compiling, I tried to add another controller but on the Add Controller dialog there this message saying "No model classes are available".
I think it happens after I NuGet EF 4.3 (upgrading from 4.1).
Any thoughts?
Thanks,
Sagy
ef4
jsiahaan
Contributor
2322 Points
596 Posts
Re: Can't create new controller, "No model classes are available"
Apr 11, 2012 12:18 PM|LINK
Hi,
You need to BUILD or REBUILD your solution any time after you create your model before you create a new controller.
Hope can help.,
Indonesian Humanitarian Foundation
sagy
0 Points
8 Posts
Re: Can't create new controller, "No model classes are available"
Apr 11, 2012 12:36 PM|LINK
Hi,
Thanks for the reply.
I already tried to build, rebuild, clean and rebuild... it doesn't help.
It happens in different projects (in different solutions), only after I upgrade from EF 4.1 to EF 4.3.
Thanks,
Sagy
Peter Xie
Member
7 Points
3 Posts
Re: Can't create new controller, "No model classes are available"
Apr 13, 2012 08:02 AM|LINK
I had same problem.
I try delete all class of DbDataController in Controllers folder. & re-build all. Then it looks can create a new control.
Then I backup all old class of DbDataController that was removed, & re-build all.
It looks like a issue, if you update EF version from EF 4.1 to EF 4.3.1 & EF 5.
ef4
sagy
0 Points
8 Posts
Re: Can't create new controller, "No model classes are available"
Apr 15, 2012 06:25 AM|LINK
So every time, when I'd like to add a new controller I have to follow this procedure?
Thanks,
Sagy
ef4
TimoYang
Contributor
3732 Points
1275 Posts
Re: Can't create new controller, "No model classes are available"
Apr 15, 2012 09:07 AM|LINK
Report this bug at:http://connect.microsoft.com/.
francesco ab...
All-Star
20912 Points
3279 Posts
Re: Can't create new controller, "No model classes are available"
Apr 15, 2012 09:43 AM|LINK
do you upgraded EF AFTER having created a DbDataController?
The point is that while in theory one can upgrade or add a Nuget package also on an existing project....in practice this is very likely to create problems, expecially if you use various type of scaffolding.
Mvc Controls Toolkit | Data Moving Plug-in Videos
sagy
0 Points
8 Posts
Re: Can't create new controller, "No model classes are available"
Apr 15, 2012 10:14 AM|LINK
I just reported it.
Thanks
sagy
0 Points
8 Posts
Re: Can't create new controller, "No model classes are available"
Apr 15, 2012 10:16 AM|LINK
No, I upgraded the EF first thing after creating the project.
Here are the steps to reproduce:
1. Open Visual Studio 2010 (Professional)
2. Create new project from the template "ASP.NET MVC 4 Web Application"
3. On the "Project Template" dialog select "Single Page Application", use Razor, leave the "Create a unit test project" option unchecked (all default)
4. Open the NuGet "Package Manager Console" and update the Entity Framework (currently to version 4.3.1) by running "Install-Package EntityFramework"
5. Build the project
6. Add a new controller by following the instructions inside the example TodoItem.cs file. Basically, creating a new controller using the Single Page Application template, using the TodoItem as the model class and creating a new data context class. This will create (among other files) a new controller inheriting from DbDataController.
7. Build the project
8. Try to add a new Controller - the Model class selection drop down box is replaced with a red X icon and a message: "No model classes are available".
Sagy
francesco ab...
All-Star
20912 Points
3279 Posts
Re: Can't create new controller, "No model classes are available"
Apr 15, 2012 12:08 PM|LINK
The point is that according to your description ACTUALLY there not other classes you can use as models for your DBDataController because you have not added new contexts or new classes to the existing context
Mvc Controls Toolkit | Data Moving Plug-in Videos