I've a project with .NET 3.5 and PetaPoco 4.0.3 (micro ORM library). I've also a reference to Oracle.DataAccess.
PetaPoco is a micro ORM library which has a T4 template to create POCO classes automatically from a Database. Database.tt
contains T4 template and creates a Database.cs
class.
When I trying to create Database.cs
from T4 template Database.tt
, I receive always the same error:
Failed to load provider `Oracle.DataAccess.Client` - Unable to find the requested .Net Framework Data Provider. It may not be installed.
I' ve debug T4 code generation and I've found that the problem is loading the Oracle driver:
/* This a part of T4 Template */
DbProviderFactory _factory;
try
{
_factory = DbProviderFactories.GetFactory(ProviderName);
}
Where ProviderName
is Oracle.DataAccess.Client
.
I tried to reproduce the problem in my Program.cs
in the same project and it works!
class Program
{
static void Main(string[] args)
{
DbProviderFactory _factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
DbConnection dbconnection = _factory.CreateConnection();
}
}
So, I am not able to understand why in the same project, DbProviderFactory
can found a driver for Oracle.DataAccess.Client
but T4 not. Which execution contexts is using T4? What can I do to solve the problem?
Thank you in advance!