如何生成城堡ActiveRecord的C#类的现有数据库 [英] How to Generate Castle ActiveRecord C# Classes for an Existing Database

查看:95
本文介绍了如何生成城堡ActiveRecord的C#类的现有数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是生成C#类与城堡的ActiveRecord和NHibernate使用给予现有的数据库结构的最佳方式是什么?

What is the best way to generate C# classes for use with Castle ActiveRecord and NHibernate given an existing database structure?

你能推荐任何的类生成工具,或只是少手工编写的类麻烦?

Can you recommend any of the class generation tools or is it just less hassle to write the classes by hand?

推荐答案

如果你只有极少数的表有没有多列,它可能是最好手工编写你的类。我不会推荐手写许多类但如果你的数据库已经存在。

If you only have a handful of tables with not many columns, it may be best to write your classes by hand. I wouldn't recommend hand writing many classes though if your database already exists.

主动作家可能会满足你的需求: http://using.castleproject.org/display/Contrib / ActiveWriter

Active Writer may meet your needs: http://using.castleproject.org/display/Contrib/ActiveWriter

有在有用的各种状态等code发电机。还有在这个叶片上的计算器等问题。这里有几个:

There are other code generators in various states of usefulness. There are other questions in this vane on StackOverflow. Here are a couple:

<一个href="http://stackoverflow.com/questions/2042967/net-orm-solution-with-class-auto-generation-subsonic-castle-ar">http://stackoverflow.com/questions/2042967/net-orm-solution-with-class-auto-generation-subsonic-castle-ar

<一个href="http://stackoverflow.com/questions/41752/nhibernate-generators">http://stackoverflow.com/questions/41752/nhibernate-generators

更新2010年6月1日:

现在我已经公开发布了城堡的ActiveRecord一(T4型)code发生器作为一个Windows应用程序:

I have now publicly released a (T4 based) code generator for Castle ActiveRecord as a Windows application:

http://www.AgilityForORMs.com/Home/Products/

有在code发电机的免费和商业版本。免费版应该只是正常工作,为广大绿地遵循某些约定的数据库(中例如:使用代理主键)

There are both free and commercial versions of the code generator. The free version should work just fine for the majority of "green field" databases that follow certain conventions (for example: using surrogate primary keys).

在AgilityForORMs城堡的ActiveRecord code发电机已经过测试,对.NET 3.5和MS SQL Server 2005/2008。支持其他数据库厂商,以及.NET 4.0,计划。

The AgilityForORMs Castle ActiveRecord code generator has been tested against .NET 3.5 and MS SQL Server 2005/2008. Support for other database vendors, as well as .NET 4.0, is planned.

我就不会写这code发电机,如果我会找到了一个现成的,我很高兴的。我想我也不妨花一些额外的时间包装它,以便其他人可以受益。

I wouldn't have written this code generator if I would have found one "off the shelf" that I was happy with. I figured I may as well spend some extra time packaging it up so other people could benefit as well.

这篇关于如何生成城堡ActiveRecord的C#类的现有数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆