T4 template for NHibernate? - not Fluent NHibernate
Asked Answered
S

10

8

Wondering if anyone knows of a set of T4 templates for generating C# POCO classes and also mapping XML files for NHibernate from a set of tables in a database. I saw that David Hayden has created T4 for generating FluentNH code based upon a DBML model, but I'm not quite ready to use FluentNH yet as there isn't even an official release yet (although I love the idea).

Anyone know of any T4 templates for using plain NHibernate?

Sinistrous answered 3/2, 2009 at 17:21 Comment(0)
S
-2

Follow-up: I decided to write my own code generator for NHibernate xml mapping file and POCO classes. I modeled it after the Linq to SQL generator in the T4 Toolbox project.

I plan to post about the experience and provide a download on my site as soon as I get the chance. Let me know if you're interested and I'll hurry it up.

Sinistrous answered 3/3, 2009 at 22:12 Comment(3)
I'm interested! I'll have to duplicate your work otherwise :-)Meng
I checked your website (blog) in the link above. Searched for NHibernate and didn't get anything relevant to T4.Forsberg
If you're going to mark your own response as the answer, then your response should be valid.Cove
R
2

May not be the answer you are looking for, but I spent a good amount of time a couple months ago looking everywhere for the same thing. I couldn't find any, though.

Not sure if you're set on using T4 for any particular reason, but I ended up using CodeSmith for code generation because there are several templates already available. There are a handful for MyGeneration, but CodeSmith was much farther along.

NOTE: If you do find some, though, you should post it here as I, and probably other people, would be rabidly interested in finding some well done T4 templates for nHibernate.

Rodeo answered 3/2, 2009 at 18:57 Comment(0)
T
1

LLBLGen's upcoming release (V3), currently in beta, will have templates for generating NHibernate POCO classes and mappings, as well as templates for EF1/4 and its own framework.

Thrill answered 4/3, 2010 at 15:22 Comment(0)
S
1

I'm trying to make one. Check it out: https://code.google.com/p/t4nh/

I use this template set in three of my projects, and it works well. Not published formerly since I still don't know if people can apply it well. Hope I can make my template set better with the community

Sabbath answered 2/11, 2010 at 12:9 Comment(2)
Looks interesting. If you can write a blog entry it, than it would be a great help for others.Yarak
@Yarak wow! I thought everyone forgot about this idea. Ok, I'll try to find spare time to make some note about it and let you know then.Sabbath
Z
1

Try Entity Developer from Devart. I need a little tweaked version for dynamic fields, but what I have seen so far looks good. I need to edit the T4 templates and would prefere to do it in VS, not in Entity Developer, which is how I found this thread...

Zaragoza answered 17/9, 2014 at 14:53 Comment(0)
F
0

CodeSmith has template for generating POCO classes and mapping files for NHibernate from a database: http://www.codesmithtools.com/video/nhibernate.html http://www.codesmithtools.com/features/frameworks.aspx

Fell answered 4/3, 2010 at 11:41 Comment(0)
F
0

If I remember correctly, S#harpArchitecture has a full set of T4 templates for generating code based on NHibernate.

Felicitation answered 4/3, 2010 at 15:19 Comment(0)
P
0

There are a couple of tools in the NHibernate trunk, Db2hbm for generating hbm.xml mapping files from the database (currently only MSSQL is supported) and Hbm2net for generating POCOs from the hbm files.

Private answered 4/4, 2010 at 10:5 Comment(0)
A
0

You can use CodeSmith for this purpose - it has its own template to generate NH classes. Of course that's not T4 but one more powerful template engine

Adalai answered 28/7, 2010 at 7:33 Comment(0)
V
0

Visual NHibernate (http://www.slyce.com/VisualNHibernate/) also supports defining templates for the entities, and generating both HBM.XML as well as Fluent NHibernate mappings. Note: I am not affiliated in any way with Visual NHibernate.

Vying answered 21/7, 2012 at 14:3 Comment(0)
S
-2

Follow-up: I decided to write my own code generator for NHibernate xml mapping file and POCO classes. I modeled it after the Linq to SQL generator in the T4 Toolbox project.

I plan to post about the experience and provide a download on my site as soon as I get the chance. Let me know if you're interested and I'll hurry it up.

Sinistrous answered 3/3, 2009 at 22:12 Comment(3)
I'm interested! I'll have to duplicate your work otherwise :-)Meng
I checked your website (blog) in the link above. Searched for NHibernate and didn't get anything relevant to T4.Forsberg
If you're going to mark your own response as the answer, then your response should be valid.Cove

© 2022 - 2024 — McMap. All rights reserved.