Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework and database column names

I'm trying to modify a POCO T4 template to include the name of the column in the database that corresponds to each property. For legacy reasons, our database tables are 8.3, and our columns are max 10 characters, so things tend to get abbriviated. Being able to quickly look up which column a given property corresponds to will be a big help.

Given that, I have no clue how to go about doing this. I'm comfortable with the idea of editing the T4 template, I just don't know how to retreive the column name from an EdmProperty object.

Can anyone point me in the right direction?

like image 275
Bobson Avatar asked Nov 14 '22 00:11

Bobson


1 Answers

I've already discussed this in some other answer but I can't find it know. The problem is that to get this information you need to browse MSL part of the mapping - the part where columns are mapped to properties. Unfortunately whole API for MSL metadata items is internal (I think one goal for future EF release is to make it public). When you have T4 template for class generation you normally work with CSDL - that is entity description and it contains only information you see in the EDMX diagram and property window for entities.

like image 77
Ladislav Mrnka Avatar answered Dec 22 '22 09:12

Ladislav Mrnka