views:

419

answers:

8

Hi, I don't even know if I'm using the correct terms but here goes:

Is there a way to map the tables and their relations in a SQL Server to domain (C# code) automatically, by means of a tool or something?

I've used the nhibernate plugin, but it creates a file in .cs and another in xml, that has the mapping, but I want that mapping to be present as "property" in the .cs file.

Sorry if this is a bit confusing.

+1  A: 

You could always use the Entity Framework or maybe Linq2SQL, but I'm not familiar with how that works.

Tho, out of EF and NHibernate, I prefer NHibernate.

DeletedAccount
A: 

Use LLBLgen of Linq 2 Sql (available in VS 2008). Or use Entity Framework (in VS 2008 SP1). Linq 2 sql allows you to drag and drop a table from sql server to the canvas and it creates a domain class for you with properties mapped to columns.

Michiel
A: 

Take a look at Fluent NHibernate and see if that is what you are looking for: http://blog.jagregory.com/2008/08/08/introducing-fluent-nhibernate/

Jonas Elfström
A: 

You can use Castle ActiveRecord which uses attributes.

gcores
A: 

I think you should read a bit about Linq to Sql

http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1269859,00.html#

Sergio
A: 

So many answers in such a short time, thanks for the help, I'll go check them now.

A: 

Check out SubSonic. It will generate your DAL and can also generates code off of custom templates.

Ben Griswold
A: 

Check out nHibernate nhforge.org

JoshBerke