dotnet / dotnet/EntityFramework.Docs
Document how to share T4 templates across projects
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
Before EF Core 7, we used to override the `ICSharpDbContextGenerator` implementation in the `IDesignTimeServices` to customize the `DbContext` generation during the scaffold. Starting EF Core 7, this approach no longer works, and we are now exploring the [t4 templates approach](https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/templates?tabs=dotnet-core-cli).
We have many (~15) DB to scaffold. Their models will be located in different folders, but they all need the same template. We have a single `Scaffold.Console` app, where we implemented our customizations, and it uses as a startup project during the scaffold. Unfortunately, putting the templates in the startup project folder doesn't work. It works only when templates are located in the destination folder (the folder where we write the generated files).
I have seen this [issue](https://github.com/dotnet/efcore/issues/27656), which was closed as `Won't do`. Any suggestion on how to reuse the same template without copying it 15 times and synchronizing the changes on every update?
Contributor guide
Assessment
This issue has not been assessed yet.