views:

233

answers:

6

I need to write a forum application for a friend's web site. I want to write it in C# 3.0 against the ASP.NET MVC framework, with SQL Server database.

So, I've two questions:

  • Should I use Linq to SQL or the Entity Framework as a database abstraction?
  • Should I use the ASP.NET Membership API or add Users table and implement it myself?

Thanks.

A: 
  1. Entity Framework definitely -- see below.
  2. ASP.net Membership API -- easy to maintain.

Reason: http://stackoverflow.com/questions/8676/entity-framework-vs-linq-to-sql

Henry Gao
+1  A: 
  1. There are lots of examples around internet which is using ling with ASP.NET MVC. But may be you can add your list NHibernate. If you do not want to add i suggest Entity Framework. Using ORM's is a plus.
  2. I always chose write my own membership management layer. If you are a person like (write your own code and be happy when you are making changes in future.) write your own membership layer. If you are looking for a quick solution ASP.NET Membership API is a good choice.
Erkan BALABAN
A: 

1) How about both? Just create an abstraction and you could just use either. My recommendation is to use the repository pattern.

2) The membership provider has its strengths and weaknesses. For some projects, it was far too complex for my needs. However, it is great if you need to get something running in a short amount of time.

zowens
i think 1 is an unnecessary abstraction for something like this, unless you are planning on distributing that component as a platform for other projects.
Matt Briggs
Not sure there is such a thing as an unnecessary abstraction when working with a database. It's fairly easy to do and it allows easy maintenance. Not sure why why you disagree... you didn't really make a point here...
zowens
More code doesn't mean easy maintenance. Layers of abstraction are always a tradeoff between code bloat, and flexibility. If you are in a case where the flexibility is unnecessary, all you are left with is more code to write, debug, and maintain. Probably 99% of the stuff I have ever done never changed the persistence story, or if they did it was in the midst of a complete rewrite. If the flexibility will realistically be needed (such as the case of distributing a starter kit, where people build on your stuff), then it makes sense to abstract out. If not, it is just extra work.
Matt Briggs
That's not the point of an abstraction. You don't test abstractions. That's pretty basic stuff. Not using abstraction results in maintainability issues going down the line. In this person's case, they aren't quite sure which they are going to use for persistence. In his case, it would make all the sense in the world to use an abstraction. Tightly coupled code in that situation wouldn't be a joy to maintain. Trust me, I've done it!
zowens
A: 

I won't answer the first question since i'm a fan of nhibernate for the second question adding a users table and implement membership yourself i don't think you will be able to do it at least the right way (lot of people tried to make their own membership api but they messed up !)

Yassir
A: 

1) Totally depends on how complex things are going to get. If you want a quick DAL that more or less mirrors your tables in a 1:1 fashion, go for L2S (or SubSonic if you want something more mature and supported). If you are going for more of an n-tier type thing where your tables and domain model are completely different, go for an OR/M like Entity Framework (or NHibernate if you want something that is pretty much better in every way)

2) ASP.net Membership is extremely complex, and there are bits of it that are fairly poorly engineered. However, it depends on how much experience you have with these things. If you enough to know how to take steps to avoid session fixation attacks, just roll your own because chances are it will be better then the canned solution. If you have no idea what that is, take the time to learn the default one.

Matt Briggs
A: 

Something to think about, SubSonic 3 is a pretty powerful data access generation tool. From what I understand, it basically wraps Linq to Sql inside of some very useful wrappers and makes using Linq a little more intutive. You can have a pretty powerful application built up in no time flat when using SubSonic. One little issue though, if you're using a shared hosting (say GoDaddy) you'll run into a medium trust issue. In that case you can always fall back to Linq To Sql without making many changes to your code base.

As for Aspnet_Membership. Just for the amount of tools it provides, I'd reccomend using it.

Good luck, and hope this helps.

Chris