MiniProfiler 加 EntityFramework 加 EFProviderWrapperToolkit?
是否可以将 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.GenericRepository
1.get_ObjectContext() 在 C:\src\MyApp.2010\MyApp.Infrastruct.Repository.EF\Repository.EF\GenericRepository.cs:81 MyApp.Infrastruct.Repository.EF.GenericRepository
1.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
1.get_ObjectSet() in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\Repository.EF\GenericRepository.cs:89
MyApp.Infrastructure.Repository.EF.GenericRepository
MyApp.Infrastructure.Repository.EF.GenericRepository`1.GetQuery() in C:\src\MyApp.2010\MyApp.Infrastructure.Repository.EF\Repository.EF\GenericRepository.cs:102
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不修改其中任何一个,答案是否定的,因为它们都替换了数据库提供程序,但这些替换不兼容。
Without modifying either of them the answer is no because they both replace database provider but those replacements are not compatible.