Add Controller Model Classes not shown

后端 未结 14 831
天命终不由人
天命终不由人 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: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.

提交回复
热议问题