How to Generate Castle ActiveRecord C# Classes for an Existing Database

佐手、 提交于 2019-12-08 05:33:25
Michael Maddox

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.

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

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

.NET ORM solution with class auto-generation: Subsonic, Castle AR, ...?

NHibernate Generators

Update June 01, 2010:

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

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

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).

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!