MiniProfiler with EF “model first” edmx model

后端 未结 2 2192
萌比男神i
萌比男神i 2020-12-28 21:14

I\'m trying to get MiniProfiler to profile my database access but I\'m running into problems. All the help I see out there seems to be for \"code first\" entity framework co

2条回答
  •  没有蜡笔的小新
    2020-12-28 21:36

    Try like this:

    var connectionString = ConfigurationManager
        .ConnectionStrings["MyConnectionString"]
        .ConnectionString;
    var ecsb = new EntityConnectionStringBuilder(connectionString);
    var sqlConn = new SqlConnection(ecsb.ProviderConnectionString);
    var pConn = ProfiledDbConnection.Get(sqlConn, MiniProfiler.Current);
    var context = ObjectContextUtils.CreateObjectContext(pConn);
    

提交回复
热议问题