简体   繁体   中英

Mapping existing tables to Domain classes in C#

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.

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.

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.

看看Fluent NHibernate,看看您是否正在寻找它: http : //blog.jagregory.com/2008/08/08/introducing-fluent-nhibernate/

您可以使用使用属性的Castle ActiveRecord

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM