views:

269

answers:

4

I have an ASP.NET MVC application which is using Linq to SQL classes placed in the Model folder.

I want to create some extra classes that I would normally place in my BLL but I'm not sure how to work this with MVC.

With WebForms I would have my DAL as a Class Library. My BLL as a class library that referenced my BLL. My Web Site that referenced both the DAL and BLL.

The problem I am facing is, if I create a class library, this will need to reference my MVC Application because it will need to use the types contained in my Model.

If I then add (or try to add) a reference to my class library, I will get a circular dependency.

In Web Forms. My other option would be to place the classes in the App_Code. Is there an equivalent of App_Code in a MVC application?

+2  A: 

You can move all your models to the class library, can't you? Neither MVC or VS mind. This would remove the dependency of the Models library on the Web app.

Lucas Jones
"Neither MVC or VS mind", I don't follow. could you expand?
Greg B
I've re-read it and I get it now ;)
Greg B
+1  A: 

You can place that in the model folder. As all the business related classed are place into that folder

For better practice see the scottgu the nerddinner examples. He has created the respiratory classes in nerdinner application.

jalpesh
thanks for the scottgu tip."You can place that in the model class" Did you mean Model folder?
Greg B
+1  A: 

I agree in terms of the Model folder. You can organize it to your heart's content (BLL, DAL, etc.).

I personally would avoid doing a separate assembly unless you have a compelling reason to. Being the kind of developer that tends to over-complicate problems if I'm not careful, I try to follow the KISS (Keep It Simple Stupid) practices as much as possible, which tends to keep me out of a certain amount of trouble.

Josh Hawthorne
+1  A: 

Try taking a look at S#arp Architecture. You can either use the template they provide or use it as a reference to help you make decisions.

http://code.google.com/p/sharp-architecture/

ajma