If you have an existing Entity Framework model (EDMX file) you generated from your database and you would like to generate POCO classes for using as Domain Classes or for Entity Framework Code First, you can easily accomplish this using Code Generation!
- Right click on your Entity Framework model and select "Add Code Generation Item"
- You will then be prompted to select a Visual Studio Template. Based on the version of Entity Framework that you are using, you can choose either "EF 5.x DbContext Generator" or "EF 6.x DbContext Generator". For my particular example, I am using Entity Framework 6, so I ended up using "EF 6.x DbContext Generator"
- Finally, once you choose your Entity Framework Code Generation template, you will then be prompted to run the template.
- When prompted with the warning dialog about running templates on your computer, make sure you click "OK" in order to allow the template to run. You may be prompted multiple times, so you may have to either click "OK" multiple times or select the checkbox for "Do not show this message again"
- Once you have completed running the code generation templates, you will have your generated code classes!
No comments:
Post a Comment