Entity Framework Custom T4 Template
Posted
by s7orm
on Stack Overflow
See other posts from Stack Overflow
or by s7orm
Published on 2010-04-20T09:03:37Z
Indexed on
2010/04/20
9:23 UTC
Read the original article
Hit count: 514
entity-framework
|T4
Hello,
I am using the Entity Framework 4.0 and I am trying to extend my POCO classes generated by the standart T4 template with some custom properties. The classes which are generated by default from EF (without T4) contain 2 properties for every navigation property - NavigationPropertyId and navigationPropertyReference. What I am trying to do is basically extend the generated POCO class with an "Id" property of the foreign key object. I know that I can do that by editing the POCO t4 template. However I have no idea how I can populate/persist the property - I guess I have to somehow extend/modify the method than converts the object to a sql query and vice versa, but I have no idea where to start.
Can anyone help?
Edit: I just found out, that the EF team has planned to implement something like this - http://blogs.msdn.com/efdesign/archive/2010/03/10/poco-template-code-generation-options.aspx (see Basic POCO with/without Fixup), however this can take ages, so I rather implement it myself.
© Stack Overflow or respective owner