I want to improve the perfermonce of EF6. So I added the template EF6 Code First Pre-generated views for c#. When running my template I have this error
Error 18 Running transformation: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. Parameter name: existingConnection at System.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName) at System.Data.Entity.DbContext..ctor(DbConnection existingConnection, Boolean contextOwnsConnection) at AccountingCore.DomainEntities.DatabaseContext..ctor() in c:\Users\wassel\Desktop\Tay_Entreprise\Migrated Taysir\Taysir Entreprise\AccountingCore\DomainEntities\DatabaseContext.cs:line 26
--- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Microsoft.VisualStudio.TextTemplating083B3A1F42B3A6F6984D21F93E2A562F18834A2D2CD4017C917BCF44C5B4413C639EC8000C24911B33CCC0A1B86BE1DE019321BC7BEBB9B61319B229A38834A7.GeneratedTextTransformation.GetEdmx(Assembly efAssembly, Type contextType) at Microsoft.VisualStudio.TextTemplating083B3A1F42B3A6F6984D21F93E2A562F18834A2D2CD4017C917BCF44C5B4413C639EC8000C24911B33CCC0A1B86BE1DE019321BC7BEBB9B61319B229A38834A7.GeneratedTextTransformation.TransformText()
This is my Context Class
public class DatabaseContext : DbContext
{
private static DatabaseContext instance;
public static DatabaseContext Instance
{
get
{
return instance;
}
}
private static DbConnection _dbConnection;
public DatabaseContext() : base(_dbConnection,false)
{
}
public static void InitialiseInstance(DbConnection connection)
{
if (instance != null)
{
instance.Dispose();
GC.SuppressFinalize(instance);
}
instance = new DatabaseContext(connection);
}
public DatabaseContext(DbConnection connection)
: base(connection,true)
{
Database.SetInitializer<DatabaseContext>(new DatabaseInitialiser());
}
public DbSet<class1> c1{ get; set; }