T4 templates in Entity Framework
Why does EF still has .tt files? How relevant are them, are them to generate code when creating a new project? Would EF work without them?
https://github.com/search?q=repo%3Adotnet%2Fefcore+.tt&type=code&p=1
14 Replies
tt files as opposed to what else? @'Wdestroier
C# Source Generators
SGs are the preferred mechanism for a live IDE experience.
EF doesn’t need that, so other mechanisms are simpler and more suitable.
Ohh k
These are all .tt files in the efcore project

I will probably check if they're very important
They are. Presumably migrations use them.
k, interesting, then in theory all .tt templates could be rewritten as a source generator
Thxx
Not for migrations.
You need to control when those happen.
And their code needs to be checked in.
If they run at runtime
Do they work with Native AOT compilation?
I guess the compiler shouldn't be available
SGs do not, but migration generation isn’t at runtime.
hmmm, I don't understand why T4 templates can't be rewritten as Source Generators for migrations
You create a new migration every time you want to have a change in your model. You need to keep all those migrations, and the output of SGs is not persistent.
Ahh, excellent
Thank you very much!