Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 4 Mapping to POCOs

I've created a new entity data model of my database and manually created the POCO objects for this to map to and it all seems to work fine.

The problem is I now want to rename the properties in my POCO objects to differ from the field names in the database e.g I want UserID rather than user_id, when I do this obviously EF then can no longer map an entity to the POCO object. Is there a way I can do this? Maybe by decorating the properties with attributes to say what maps to them?

like image 382
Gavin Avatar asked Nov 27 '25 19:11

Gavin


1 Answers

You can change it in Entity Designer. Enity Data Model (EDM) contains 3 main parts:

  • Conceptual model. What objects do you want to save.
  • Storage model. What database structure do you have.
  • Mapping. How to map objects to database.

POCOs are actually 'defined' in your conceptual model. Open Edmx file in Model Designer. Locate User entity there and change the name of the property.

like image 82
Yury Tarabanko Avatar answered Nov 30 '25 08:11

Yury Tarabanko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!