Based off of James Close's comment, I was able to write the following template for debugging my file paths:
<#@ template language="C#" debug="true" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#><#@
output extension=".txt"#><#
/////////Some standard-ish settings, continue reading on
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, 1);
MetadataTools ef = new MetadataTools(this);
/////////Below are the relevant sections I used for debugging
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//Gives you the location of MySolution.sln
string edmxFile = solutionsPath + "MyDAL/MyDAL/MyModel.edmx"; //Note - VS projects usually have a subdir with the same name as the sln, hence the repetition for MyDAL
#>
Does this file exist?
<#
//
if (File.Exists(edmxFile))
{
//Continue.
#>
Yes
<#
}
else
{
#>
No
<#
}
#>
This will generate a .txt file and will very quickly help you debug whether your path could be located or not.
As a side note, in cases where there was a relative dir path (e.g. ../App.config
) that couldn't be located, I found that it helped to put a file (e.g. test1.txt
) at each directory level, as I figured out that Host.ResolvePath
wasn't able to see outside the current assembly with my setup. This caveat can get confusing very quickly since ../../App.config
might resolve to MySolution\App.config
, but ../../MyDal/README.txt
won't resolve (hence the file won't be found), even if that is the correct path. The above code seems to negate this problem as far as I can see.
The above solution might also be a resolution to this issue - How to use the poco entity generator