**Unable to cast object of type 'MvcMiniProfiler.Data.EFProfiledDbConnection' to type 'System.Data.SqlClient.SqlConnection'.**

I am trying to upgrade to MvcMiniProfiler 1.9.0 and I keep getting this when I call MiniProfilerEF.Initialize(). I have removed the system.data config section. I don't know what I am doing wrong. I have followed the steps on the site, but maybe I missed something?

I am using EF code first 4.1 and I am passing in the name of my connectionstring into a constructor to create my datacontext.

Web Activator

```
using Project.Web.App_Start;
using WebActivator;

[assembly: PreApplicationStartMethod(typeof(MiniProfiler), "Start")]

namespace Project.Web.App_Start {
    public class MiniProfiler {
        public static void Start()
        { 
            if (Eco.Environment.IsDevelopment) {
                MiniProfilerEF.Initialize();
            }
        }
    }
}

```

StructureMap Registry: 

```
using Project.Domain.Repositories;
using StructureMap.Configuration.DSL;

namespace Project.Web.DependencyResolution.Registries {
public class RepositoriesRegistry : Registry {
    public RepositoriesRegistry() {
        For<IProjectDataContext>().HybridHttpOrThreadLocalScoped().Use(() => new ProjectDataContext(Eco.Database.Name));
          }
    }
}

```

DataContext Constructor: 

```
    public ProjectDataContext(string nameOrConnectionString)
        : base(nameOrConnectionString) {
        Active = new Active(this);
    }

```

I have removed system.data dataproviders fron my config since the documentation says I only need to call MiniProfilerEF.Initialize().

\*\*Update 

Previously in 1.7 MvcMiniProfiler I had to set the Database.DefaultConnectionFactory property, but I've removed that. The Database.DefaultConnectionFactory always comes back as SqlConnectionFactory, shouldn't it be ProfiledConnectionFactory or something like that?