I'm trying to use the new mvc-mini-profiler with my EF4 based app, but I have no idea how to properly get a connection to my destination datasource.
Here's as far as I have gotten.
Func<IMyContainer> createContainer = () =>
{
var profiler = MiniProfiler.Current;
if (profiler != null)
{
var rootConn = // ????
var conn = ProfiledDbConnection.Get(rootConn);
return ObjectContextUtils.CreateObjectContext<MyContainer>(conn);
}
else
{
return new MyContainer();
}
};
kernel.Bind<IMyContainer>().ToMethod(ctx => createContainer()).InRequestScope();
How do I get a connection to an EF container, without the contianer itself? I would just new-up a SqlConnection, except that the connection string is wrapped in all of the EF junk.
(MyObjectContext.Connection as EntityConnection).StoreConnection
?MyContainer
yet.