views:

1545

answers:

8
+2  Q: 

ASP.NET MVC + ORM

I am in the start up of a project using ASP.NET MVC and have started creating my models. Since I know some Ruby On Rails and would like to use a system as similar to Rails Active Record as possible.

Have anyone used Castle Projects Active Record in a ASP.NET MVC application (or any application that is relevant) and have some experience to share?

Are MVC and Castle Active Record the right way to go or do you suggest I use LinqToSql instead.

Please share any thoughts and experiences you might have gain.

Edit: To clarify; I come from a long ASP.NET and C# background but have looked a little at Rails and love how easy you can create the ORM

A: 

Use linq to sql first.

fooledbyprimes
+1  A: 

Coming from a Rails background, Castle Project AR will feel closer to what you're used to, but Linq to SQL is better integrated with the whole Microsoft ecosystem and you may find this is worth the extra effort to learn it.

Ryan
+2  A: 

Linq to SQL has some major missing pieces, notable many to many relationships. If you're going the "pure" Microsoft route look at .net 3.5 sp1 and Linq to Entities, which uses the new ADO.net Entity Framework.

Jeff Mc
Sounds intresting!
ullmark
you can simulate many to many with method extensions
Hrvoje
+1  A: 

I've used the Castle ActiveRecord with MonoRail and it is fairly easy to use and intuitive, although the innevitable problems you'll come across are often hard to diagnose. Its documentation is also not the best (as with many open source projects). By default it uses NHibernate ORM underneath, and if you were specifically after using an ORM framework I believe there has been some effort to support LINQ with NHibernate, no idea how far it is along though.

I think it also depends on the size of the application, if its a quick project that won't necessarily be maintained heavily then the ease-of-use ActiveRecord gives might be handy, but then LINQ also seems pretty easy and neat. If it was a larger application I would consider rolling your own data layer using NHibernate, again if its specifically the ORM you want.

roryf
+4  A: 

I have used Castle Active Record with ASP.NET MVC. I highly encourage this model, as ActiveRecord/NHibernate are much more mature that LINQ to SQL or the Entity Framework.

I think that ASP.NET MVC has a bright future and would recommend it over Monorail for new projects. However, as I said, ActiveRecord is (in my view) a superior ORM to LinqToSQL.

Mike
Mike, how did you get around the issue of ASP.NET MVC requiring strongly named assemblies for scaffolding? Thx.
consultutah
A: 

Do you need the ORM to be free (as in beer)/open source?

If you don't then I would highly recommend eXpress Persistent Objects from DevExpress.

If not, then I dont think LINQ is similar, I haven't used ActiveRecord from Castle but I guess that's the most similar to RoR

Gustavo Rubio
A: 

MVC doesn't know what ORM you are using, or is there even some ORM tool behind. Controller/Action must send object references to View, so that object can be simple int, string array, DataSet, Linq object, ActiveRecord object, whatever, it doesn't matter for View how some object is filled with data!

Hrvoje
A: 

Prefer NHibernate as your persistence layer.

Samnang