0

I have a solution with one project (Project1). I added another project (Project2). Both of them are Web Application MVC 5.

In the Controller of Project 2 I cant use using Project2.Models but I can use using Project1.Models In autocomplete list after I type Project2. It only shows the Controller and not Model. How to reference Models of Project2 on Controller of Project2?

Additional info:
From Controller on Project1 on autocomplete list Project2 doesn't appear. Also for Models on Project2 I added them from existing items (items from Models on Project1).

1
  • This doesn't seem like a good practice wht asp.net mvc, what's your purpose of separating these web projects in the first place? Commented May 16, 2016 at 10:53

2 Answers 2

1

Since you copied the models from Project1 to Project2, make sure you update the namespaces of Project2 models so they point to Project2.

Also make sure the models in Project2 are Public.

Sign up to request clarification or add additional context in comments.

Comments

0

I'm assuming you have 2 projects in your solution, you need to add reference to project2 in project1.

  1. Right-click references in project1
  2. select "Add reference"
  3. select Projects
  4. select Project2

enter image description here

Note:

Usually in a website there is only one project per site. A reference to something by a website would usually be a server side service/app of some sort. If you are doing what you do to split the site, then take a look into Area.

And remember you can only access the methods, classes and such that is public, internal is public for a project, and not external projects. and private and protected you should already know.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.