I have the same code in a t4 template and in a unit test. Both reference the same assemblies: Unit test executes succefully, t4 return error: Running transformation: System.MissingMethodException: Method not found: 'System.Data.Entity.DbSet`1
T4 Template:
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" #>
<#@ assembly name="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" #>
<#@ assembly name="C:\VSProjects\VS.CodeGen\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll" #>
<#@ assembly name="C:\VSProjects\VS.CodeGen\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll" #>
<#@ assembly name="C:\VSProjects\VS.CodeGen\VS.CodeGen.Source\bin\Debug\VS.CodeGen.Source.dll" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="VS.CodeGen.Source.Models" #>
<#@ output extension=".cs" #>
<#
var connectionString = "Data Source=MyComputer;Initial Catalog=GenSource;Integrated Security=True;MultipleActiveResultSets=True";
using (var ctx = new GenSourceContext(connectionString))
{
var dsp = ctx.Dsps;
}
#>
Test Code:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VS.CodeGen.Source.Models;
namespace VS.CodeGen.Test
{
[TestClass]
public class TestT4
{
[TestMethod]
public void TestMethod1()
{
var connectionString = "Data Source=MyComputer;Initial Catalog=GenSource;Integrated Security=True;MultipleActiveResultSets=True";
using (var ctx = new GenSourceContext(connectionString))
{
var dsp = ctx.Dsps;
}
}
}
}
What's causing the error?
Thank you!