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
jcotton42
jcotton422d ago
tt files as opposed to what else? @'Wdestroier
'Wdestroier
'WdestroierOP2d ago
C# Source Generators
jcotton42
jcotton422d ago
SGs are the preferred mechanism for a live IDE experience. EF doesn’t need that, so other mechanisms are simpler and more suitable.
'Wdestroier
'WdestroierOP2d ago
Ohh k
'Wdestroier
'WdestroierOP2d ago
These are all .tt files in the efcore project
No description
'Wdestroier
'WdestroierOP2d ago
I will probably check if they're very important
jcotton42
jcotton422d ago
They are. Presumably migrations use them.
'Wdestroier
'WdestroierOP2d ago
k, interesting, then in theory all .tt templates could be rewritten as a source generator Thxx
jcotton42
jcotton422d ago
Not for migrations. You need to control when those happen. And their code needs to be checked in.
'Wdestroier
'WdestroierOP2d ago
If they run at runtime Do they work with Native AOT compilation? I guess the compiler shouldn't be available
jcotton42
jcotton422d ago
SGs do not, but migration generation isn’t at runtime.
'Wdestroier
'WdestroierOP2d ago
hmmm, I don't understand why T4 templates can't be rewritten as Source Generators for migrations
jcotton42
jcotton422d ago
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.
'Wdestroier
'WdestroierOP2d ago
Ahh, excellent Thank you very much!

Did you find this page helpful?