MiniProfiler 加 EntityFramework 加 EFProviderWrapperToolkit?

发布于 2024-12-11 12:07:23 字数 2486 浏览 0 评论 0原文

是否可以将 MiniProfiler 1.9 与 EntityFramework 以及 EFProviderWrapperToolkit 一起使用?我还使用从数据库更新 edmx 方法,而不是首先使用代码。

我已经安装了 EFProviderWrapperToolkit 并且运行得很好,它的缓存提供程序有很大的不同。但它似乎与 MiniProfiler 发生冲突:

protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        //MiniProfiler.Start();
        MiniProfilerEF.Initialize();
    }
}

这可能是因为 MiniProfiler 和 EFProviderWrapperToolkit 都试图包装 数据库连接。

给出此错误消息:

无法转换“MvcMiniProfiler.Data.EFProfiledDbConnection”类型的对象 输入“EFProviderWrapperToolkit.DbConnectionWrapper”。

第 229 行:DbProviderFactory 工厂 = DbProviderFactories.GetFactory(invariantName); 第 230 行:var connectionWrapper =factory.CreateConnection(); 第 231 行:DbConnectionWrapper 包装器 = (DbConnectionWrapper)connectionWrapper; 第 232 行:wrapper.WrappedConnection = 连接; 第233行:connection = connectionWrapper;

[InvalidCastException:无法将“MvcMiniProfiler.Data.EFProfiledDbConnection”类型的对象转换为“EFProviderWrapperToolkit.DbConnectionWrapper”类型。] C:\src\MyApp.2010\EF4ProviderWrappers\EFProviderWrapperToolkit\DbConnectionWrapper.cs:231 中的 EFProviderWrapperToolkit.DbConnectionWrapper.WrapConnection(DbConnection 连接,String[]wrapperProviderInvariantNames) EFProviderWrapperToolkit.EntityConnectionWrapperUtils.CreateEntityConnectionWithWrappers(字符串entityConnectionString,EntityConnectionStringBuilder ecsb,String []wrapperProviders)在C:\ src \ MyApp.2010 \ EF4ProviderWrappers \ EFProviderWrapperToolkit \ EntityConnectionWrapperUtils.cs:60 MyApp.Infrastruct.Repository.EF.ExtendedMyAppContext..ctor(字符串connectionString,EntityConnectionStringBuilder ecsb)在C:\ src \ MyApp.2010 \ MyApp.Infrastruct.Repository.EF \ ExtendedMyAppContext.cs:19 C:\src\MyApp.2010\MyApp.Infrastruct.Repository.EF.ObjectContextManager.GetObjectContext() 中的 MyApp.Infrastruct.Repository.EF\Repository.EF\ObjectContextManager.cs:62 MyApp.Infrastruct.Repository.EF.GenericRepository1.get_ObjectContext() 在 C:\src\MyApp.2010\MyApp.Infrastruct.Repository.EF\Repository.EF\GenericRepository.cs:81 MyApp.Infrastruct.Repository.EF.GenericRepository1.get_ObjectSet() 在 C:\src\MyApp.2010\MyApp.Infrastruct.Repository.EF\Repository.EF\GenericRepository.cs:89 MyApp.Infrastruct.Repository.EF.GenericRepository`1.GetQuery() 在 C:\src\MyApp.2010\MyApp.Infrastruct.Repository.EF\Repository.EF\GenericRepository.cs:102

Is it possible to use the MiniProfiler 1.9 with EntityFramework and also with EFProviderWrapperToolkit? I'm also using the update edmx from database method, not code first.

I have EFProviderWrapperToolkit already installed and working very well, it's caching provider makes a big difference. But it seems to clash with the MiniProfiler:

protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        //MiniProfiler.Start();
        MiniProfilerEF.Initialize();
    }
}

It is probably because both MiniProfiler and EFProviderWrapperToolkit are attempting to wrap the
db connection.

Gives this error message:

Unable to cast object of type 'MvcMiniProfiler.Data.EFProfiledDbConnection'
to type 'EFProviderWrapperToolkit.DbConnectionWrapper'.

Line 229: DbProviderFactory factory = DbProviderFactories.GetFactory(invariantName);
Line 230: var connectionWrapper = factory.CreateConnection();
Line 231: DbConnectionWrapper wrapper = (DbConnectionWrapper)connectionWrapper;
Line 232: wrapper.WrappedConnection = connection;
Line 233: connection = connectionWrapper;

[InvalidCastException: Unable to cast object of type 'MvcMiniProfiler.Data.EFProfiledDbConnection' to type 'EFProviderWrapperToolkit.DbConnectionWrapper'.]
EFProviderWrapperToolkit.DbConnectionWrapper.WrapConnection(DbConnection connection, String[] wrapperProviderInvariantNames) in C:\src\MyApp.2010\EF4ProviderWrappers\EFProviderWrapperToolkit\DbConnectionWrapper.cs:231
EFProviderWrapperToolkit.EntityConnectionWrapperUtils.CreateEntityConnectionWithWrappers(String entityConnectionString, EntityConnectionStringBuilder ecsb, String[] wrapperProviders) in C:\src\MyApp.2010\EF4ProviderWrappers\EFProviderWrapperToolkit\EntityConnectionWrapperUtils.cs:60
MyApp.Infrastructure.Repository.EF.ExtendedMyAppContext..ctor(String connectionString, EntityConnectionStringBuilder ecsb) in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\ExtendedMyAppContext.cs:19
MyApp.Infrastructure.Repository.EF.ObjectContextManager.GetObjectContext() in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\Repository.EF\ObjectContextManager.cs:62
MyApp.Infrastructure.Repository.EF.GenericRepository1.get_ObjectContext() in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\Repository.EF\GenericRepository.cs:81
MyApp.Infrastructure.Repository.EF.GenericRepository
1.get_ObjectSet() in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\Repository.EF\GenericRepository.cs:89
MyApp.Infrastructure.Repository.EF.GenericRepository`1.GetQuery() in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\Repository.EF\GenericRepository.cs:102

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青朷 2024-12-18 12:07:23

如果不修改其中任何一个,答案是否定的,因为它们都替换了数据库提供程序,但这些替换不兼容。

Without modifying either of them the answer is no because they both replace database provider but those replacements are not compatible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文