简体   繁体   中英

Change EF Entity naming pattern when generating model from database

Is there a way to change the pattern that EF uses to generate the Entity name when generating the EDM model from an existing database?

Example:

I have a table: table_name and I want my entity to be named TableName without me having to change it manually.

EDIT: I know I can change the POCO generation template, but how about the EDM generation? Is this done with a template as well? If so, where is this template located?

I'm affraid it is not possible - at least not without investigating possibilities of EF Designer extensibility or investigating EdmGen internals. The point of Entity designer is to allow you easily map / change those names.

Interestingly it is possible if you start with model (EF designer) and want to generate database from the model - in such case the process is controlled by workflow and T4 templates and you can change it but in case of generating model from database the process is most probably hardcoded inside Edmgen tool - you can check if this tool has any API which would allow you changing the behavior.

Anyway EDMX is just XML so if you have exact pattern you need to replace you can create very simple tool, transformation or script which will modify your EDMX file after generation from the database.

You cannot change the POCO T4 template. The template must produce classes with exactly same names as you have for entities in your model. Otherwise the POCO magic will not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM