views:

351

answers:

0

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.