Is it possible to permanently change the mapping details for an entity in EF 4 model-first? I want to be able to map entities to specific table and column names. I can do this in the Entity Designer, but these custom mappings are destroyed when I use “Generate Database From Model” to create a deployment SQL script.
The reason I need to do this is that while I have control over most of my table definitions, in a few cases, I need to use specific table definitions expected by an external application. These tables and columns are (IMO) poorly-named, and I want to use friendlier names for the associated entities in my C# code.
Yes there is a way but it is a lot of work to do. You must use custom structural annotation where you define expected name and you must modify T4 templates for MSL and SSDL generation which will use the name from annotation instead of the name of property (I hope it will work in the same way as it works with SQL script generation). It works only in EFv4.