I like to customize the T4 templates used by Entity Framework 6.1 in Code First workflow.
I have 2 projects in my MVC app, one for Data Access (DAL) and other for Domain Entities (Model). I am using "Code First from database" Entity Data Model wizard in DAL project to generate context and POCOs.
However, I want to customize the T4 templates so that it generates data objects in Model project and let DbContext sit in DAL project (Separation of Concerns). So I have installed EntityFramework.CodeTemplates.CSharp NuGet package (http://msdn.microsoft.com/en-US/data/dn753860).
If it's not doable, I want to customize T4 templates so that I can store domain objects in separate folder.
Second thing which surprises me is how can I re-engineer my models if my DB changes? Do I need to add a new model each time?
I am having difficulty in customizing these T4 templates used by EF in CodeFirst due to lack of documentation.
Thanks for your help!
I opted for non-OOB solution by relying on "EntityFramework Reverse POCO Generator" extension. This IMHO is much better than OOB wizard which sucks and beta version of power tools.
Thanks for all the opinions and agreeing with me that the OOB wizard needs re-thinking by MS.
About the change in model, since it is code first approach, that means your models are driving the whole thing. So you can change your models as many times as you want, just use the following command in package manager console, to generate code that will change the database accordingly
And to execute your changes use
To have your models seperate from data access layer, you may have to specify a connection string (which points to the correct folder in your project):