I have a solution that has a few projects in it. I’d like to create some T4 templates in one of my test projects to generate tests based on code in another project. The test project has a Project Reference to the other project. The problem I have is that I don’t know how to get a file path to the edmx file I need to generate code from.
Example (pretend this is an ASCII-based Solution Explorer):
MySolution.sln
-> MyTests.csproj (C:\a\b\c\)
----> GeneratedTests.tt (C:\a\b\c\GeneratedTests.tt)
-> MyDAL.csproj (C:\x\y\z\)
----> MyModel.edmx (C:\x\y\z\MyModel.edmx)
How would my GeneratedTests.tt be able to get a file path for MyModel.edmx utilizing its project reference to it?
This doesn’t work that way. You’ll have to reference the dll by path (you can find that out with
Host.ResolvePathand use theVolatileAssemblytag from the toolbox to be able to recompile it without restarting VS ) and use reflection to work on the Model.