views:

438

answers:

5

I am still trying to figure out the right architecture for a complex ASP.NET MVC web application.

I looked in a lot of example code and everywhere it's done differently.

I would really appreciate your thoughts on this.

Another Question: Would you use Linq to SQL or the Entity Framework?

Thanks,

-Ben

A: 

Everywhere is different, that's why. There is no one-size-fits-all answer to this question. Look at the other approachs, and take anything that you find useful for your situation from them.

David M
+2  A: 

Since you are going for an MVC application, you can easily write a DataAccess layer below the Controller layer. That will make it a layered application. So this could be proper option for your architecture need.

For the LinQ-SQL or Entity Framework question, I have used only Entity frameworks. So not sure about the Linq to Sql option. But there are certain problems with Entity Framework when the schema changes. The updation of the generated edmx does not happen properly when columns are renamed etc. So what I do is delete and create the edmx after every schema change and you have to manually update the changes there.

Xinxua
+3  A: 

Some personal thoughts and experiance:
- use nhibernate as orm, or wait for EF v4. Tekpub.com has good tutorial on using NH. L2S and EF are kind of black box: they are doing lot of things, they have good documentation, but they don't have extendability point. If you want to plug in some new functionality or change behavior, you can do that only with NH. EF in v4 will be in state where NH was 2 or 3 years before.
- browse as much examples of MVC apps as you can find. Lot of them you can find on codeplex. For example: CodeCampServer, WhoCanHelpMe, Storeddd
- if you're thinking of building framework (or helper) to solve some infrastructure problems, google for it first; it's high probability that someone else smarter than you (well, smarter than me in my case) already had the same problems, and wrote nice piece of code in form of framework (object mapper, validation, messaging,...), or just blogged about it.
- using sharp architecture or fubuMvc solves much of infrastructure work, but rest of app depends on you business model.
- TDD will force you to write good and maintainable code. Try using Gang of Four design patterns and SOLID principles as much as you can.

Hrvoje
+1  A: 

Would you use Linq to SQL or the Entity Framework?

Linq2SQL is great if you want to access an object model that directly maps onto your database. For example, if you have an "Orders" table, Linq2SQL will create an "orders" object which you can use to access the data. This is often completely adequate.

Entity Framework is useful when you want to create an object model that might not directly map to the database.

CraigS
+1  A: 

Check this Architecture Guide: ASP.NET MVC + N-tier + Entity Framework and Many More

If you want to use ASP.NET MVC but is strugling to get things arrange to confidently use for your next business project. This Article is just for you. The article guide you to use ASP.NET MVC to architect a small Document Management System.

Nirosh