Second error: you don't need to reference your own exe. Because
- Assembly directive is for assemblies, not executables
- You use only standard classes
- This exe is built using the output of your T4, recursion ?)
Also Connection String to local database is not to your exe, it's like
conn = new SqlCeConnection("Data Source = MyDatabase.sdf; Password ='<pwd>'");
Rest of your code looks good. And Your first error is from a bad generated file, because it's like this
ErrorGeneratingOutput