2

As you know,There are Models, Views and Controllers in a same project in ASP.NET MVC. But I want separate Models from others and create my models in a separate project (like ClassLibrary project or whatever is possible).

How can I do it?

(I use EF6 and ASP.MVC 4,5 and Visual studio 2013)

1 Answer 1

9

Create a class library for Models and add it's reference in MVC project. It should work

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

2 Comments

+1. Note that "Models" in ASP.Net MVC are "view models", not "domain models" as in classic MVC pattern - so usually models are in the same project as corresponding views. Also if you have any EF classes in you your models you'll need much bigger refactoring than just moving models to other assembly.
Make sure you've added reference to Model class library

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.