简体   繁体   中英

Constructors on Generated Entities with Entity Framework

I looked around on how to do this ( see here ) but I still am not clear on how to create constructors for generated entity classes?

How do I do that?

CodeCaster has the right idea.

If your entity classes are partial, you can create another piece of the class that extends the definition of the entity into a file that will not be regenerated every time you save the edmx.

Keep in mind that when you make updates to the edmx from your database (table changes, column type changes etc.) you may need to revisit the partial class file you defined to make sure that it works correctly with the new changes, because EF won't have any context for that extension of the entity class.

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