codiiv codiiv - 17 days ago 6
C# Question

Visual studio 2015 NOT detecting Controllers and Models I added manually

I am new to Visual Studio and C#.

I created a MVC project project and named it let's say XYZ. It runs fine and contains two custom Controllers and 2 Models.

I then created another project I will call XYZ2. I copied the 2 controllers and 2 models from project XYZ in Windows Explorer

(manually from "Controllers" and "Models" folders respectively)
.

Now when I access XYZ2 in Visual Studio the two files are NOT showing. What is wrong and what is the reasoning behind?

Answer

In Visual Studio, open your solution and click here to show all files in the file system:

enter image description here

Then in the Solution Explorer, include the files in project (Right click the file -> Include In Project):

enter image description here

ALTERNATIVELY, you may right-click in your solution -> Add -> Existing Item and this will open a file explorer window where you can select the files you wish to add.