实体框架 – 具有实体框架的MVC MiniProfiler 5模型第一个错误:
使用实体框架5,MiniProfiler 2. Nuget安装MiniProfiler.EF.
创建连接如下 var conn = new EFProfiledDbConnection(DbConnections.GetSqlConnection(),MiniProfiler.Current); return new MyDbContext(conn,true); 当尝试使用DbContext检索数据时,将返回以下错误: Unable to determine the provider name for connection of type 'StackExchange.Profiling.Data.EFProfiledDbConnection'.` 我已经尝试将以下内容添加到web.config中: <system.data> <DbProviderFactories> <remove invariant="StackExchange.Profiling.Data.ProfiledDbProviderFactory" /> <add name="StackExchange.Profiling.Data.ProfiledDbProviderFactory" invariant="StackExchange.Profiling.Data.ProfiledDbProviderFactory" description="StackExchange.Profiling.Data.ProfiledDbProviderFactory" type="StackExchange.Profiling.Data.ProfiledDbProviderFactory,MiniProfiler,Version=2.0.2.0,Culture=neutral,PublicKeyToken=b44f9351044011a3" /> </DbProviderFactories> </system.data> 这没有帮助.我也尝试过使用MiniProfiler.EntityFramework中不同的EFProviderFactories的变体,但是无法让任何一个工作. 如果我尝试运行MiniProfilerEF.Initialize();在App_Start中,当尝试访问DB时,我会收到以下错误消息:
从web.config中删除DbProviderFactories部分并运行MiniProfilerEF.Initialize_EF42();在App_Start中导致原始错误. 由于MiniProfiler页面说MiniProfilerEF.Initialize()仅用于代码,这似乎不是要走的路. 其他搜索没有给我任何其他的东西要尝试,除了添加到Web.Config的部分.有关如何进行的建议?目标是能够使用Mvc MiniProfiler分析的Model First DbContext. 解决方法
你的global.asax看起来像这样吗?
public class MvcApplication : HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); AutomapperConfig.RegisterMappings(); MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter(); MiniProfilerEF.Initialize(); } protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } } protected void Application_EndRequest(object sender,EventArgs e) { MiniProfiler.Stop(false); } } 我定期实例化我的上下文: var _database = new DinoContext(_connectionString); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – 在视图中创建DropDownListFor项
- Razor Page Library:开发独立通用RPL(内嵌wwwroot资源文件
- asp.net – 无效的回发或回调参数.为什么?
- asp.net-core – 如何从.net核心连接到Sybase数据库
- asp.net-mvc – 具有WebApi和Controller路由的Url.Action
- asp.net-mvc – 是否有一种方法来创建一个ActionLink与HTML
- asp.net-mvc – 发现MVC项目中是否使用views / partials
- 问题在ASP.NET中使用System.Web.Caching.Cache类
- asp.net-mvc – 如何清除ASP.NET MVC应用程序中文本框的发布
- ASP.NET mvc:如何使用今天的日期自动填充日期字段?
- WF4 – 在asp.net中显示工作流图像,并突出显示活
- 使用VSCode,DNX和kestrel运行第一个ASP.NET 5应用
- forms-authentication – 在OWIN托管的SignalR实
- ASP.NET MVC C#在类中获取控制器和操作名称
- asp.net-mvc – 如何使用ASP.NET Core,2.0中的Ra
- VS 2015预览缺少“ASP.NET 5 Web应用程序”项目类
- asp.net – 使用JQuery从viewstate获取值?
- 为什么我的IIS7应用程序池在从ASP.NET页面调用的
- asp.net-mvc-3 – 将其他数据发送到Telerik MVC网
- asp.net-mvc – 将动作方法参数传递给asp.net mv