adamwtiko
adamwtiko

Reputation: 2905

ASP.NET MVC 3 ViewModels in a different project?

Is there anything from stopping you placing ViewModels in a different project?

I basically have a DataModel (Entity Framework) project, Data Access project (might merge this into the DataModel), Business Logic project and the ASP.NET MVC website. I want the Business Logic layer to return ViewModels so was wondering if these can be separate from the website code.

Upvotes: 3

Views: 1319

Answers (2)

Aaronontheweb
Aaronontheweb

Reputation: 8394

Absolutely - you just need to reference the DLL in your MVC3 project and then reference those ViewModels in your strongly typed views.

Just make sure you declare

@model SeperateAssembly.ViewModelName

At the top of your views to make them strongly typed.

Upvotes: 3

WestDiscGolf
WestDiscGolf

Reputation: 4108

Short answer : no

Long answer : no reason. It will make you have to think more about dependencies of project references and bits. You'll just have to be careful with the design when it comes to references etc.

Hope that helps.

Also, can help with unit testing :-)

Upvotes: 1

Related Questions