Add Controller Model Classes not shown

后端 未结 14 748
天命终不由人
天命终不由人 2020-12-31 09:41

I managed to create a Model First DBContext model (before it was a normal ObjectContext derived model).

Strangly now my VS is not showing ANY of my classes in the Mo

相关标签:
14条回答
  • 2020-12-31 10:02

    Had the same problem with an EF model in a separate project to begin with.

    Rebuild all did nothing, but simply reloading into a new instance of Visual Studio fixed it.

    0 讨论(0)
  • 2020-12-31 10:03

    I just experienced this issue in a project that had been working. There were NO updates to EF or MVC, it just started throwing the "There no model classes..." message. I backed up my project, deleted it from my HD and the got the most recent version from source control, SVN in this case. I rebuilt the project and now it works again, just like magic.

    VS 2012 EF 5.0 .NET 4.5 MVC 4.0

    0 讨论(0)
  • 2020-12-31 10:04

    The reason it worked is that by putting it in another project you "built" it and then it showed up. If you would have built your first project and then tried to add a controller bam it would be there.

    0 讨论(0)
  • 2020-12-31 10:04

    Create a new MVC internet site. Add existing (your model classes) - verify it works, then start diffing the two projects.

    0 讨论(0)
  • 2020-12-31 10:06

    Had the same problem. Found that just Building the project didnt solve the problem of the missing Model classes. Rebuilding the project however, solved it right away.

    0 讨论(0)
  • 2020-12-31 10:10

    I was having a similar problem, despite ensuring that I included

    using ProjectName.Models; 
    

    at the top of my controller file. Building/Rebuilding didn't work for me. Nor did closing all instances of Visual Studio, and reopening project.

    I thought the problem might be that we are using TFS (Team Foundation Server by Microsoft). I had the problem because I initially created the model and then created my controller within the views folder, before I moved that controller (file) to the controllers folder.

    My solution was to create my model, copy controller code elsewhere, delete the controller, rebuild/build the solution. Then I created a new controller, copied the correct code back in, and hey presto, it recognised the model class.

    0 讨论(0)
提交回复
热议问题