Reputation: 131
I'm starting a new project and want to use EF Code First pattern but I also want to use the repository pattern. I have been looking for a way to generate the repositories from the dbcontext models but all answers I've seen so far are for generating repositories from .edmx or DB. I don't want to create an .edmx.
The steps I want to do is this:
1. Write models
2. Generate repositories using t4 templates
3. Write app code from models and repos
4. Run Add-Migration to add migration code
5. Run update-database to update based off migration code
What could I use to tell it to generate t4 templates based on the model classes?
Upvotes: 2
Views: 1366
Reputation: 1934
There is a NuGet package I created which does this as well, it requires a namespace your models not a edmx file:
https://www.nuget.org/packages/RepositoryGenerator/
Upvotes: 0
Reputation: 131
I've found how to do it now. Using T4Scaffolding, I am going to be able to generate the repositories as I need. It also allows me to override the default t4 templates and create custom scaffolds too.
Upvotes: 1