无法找到请求的 .Net Framework 数据提供程序.它可能没有安装.- 在遵循 mvc3 asp.net 教程时

Unable to find the requested .Net Framework Data Provider. It may not be installed. - when following mvc3 asp.net tutorial(无法找到请求的 .Net Framework 数据提供程序.它可能没有安装.- 在遵循 mvc3 asp.net 教程时)

本文介绍了无法找到请求的 .Net Framework 数据提供程序.它可能没有安装.- 在遵循 mvc3 asp.net 教程时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 ASP.NET MVC 3 音乐商店应用程序教程,但我一直卡在第 4 部分:http://www.asp.net/mvc/tutorials/mvc-music-store-part-4.它一直告诉我我没有安装 SQL 数据提供程序:

I am following the ASP.NET MVC 3 Music store application tutorial but I keep getting stuck in part 4: http://www.asp.net/mvc/tutorials/mvc-music-store-part-4. It keeps telling me that I do not have the SQL data provider installed:

确切的错误:

System.ArgumentException was unhandled by user code
  Message=Unable to find the requested .Net Framework Data Provider.  It may not be installed.
  Source=System.Data
  StackTrace:
       at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
       at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name)
       at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
       at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
       at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
       at System.Data.Entity.Internal.InternalContext.Initialize()
       at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
       at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
       at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
       at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at MusicApplication.Controllers.StoreController.Index() in C:UsersMichelledocumentsvisual studio 2010ProjectsMusicApplicationMusicApplicationControllersStoreController.cs:line 18
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
  InnerException: 

我已经添加了对 System.Data.SqlServerCe 的引用 - 仍然有同样的错误.任何指导将不胜感激

I have added the reference to System.Data.SqlServerCe - still have the same error. Any guidance would be really appreciated

推荐答案

我能够使用 NuGet 在 Visual Studio 2010 中解决与此类似的问题.

I was able to solve a problem similar to this in Visual Studio 2010 by using NuGet.

转到工具">库包管理器">管理解决方案的 NuGet 包..."

Go to Tools > Library Package Manager > Manage NuGet Packages For Solution...

在对话框中,搜索EntityFramework.SqlServerCompact".您将找到一个包,其描述为允许 SQL Server Compact 4.0 与实体框架一起使用".安装这个包.

In the dialog, search for "EntityFramework.SqlServerCompact". You'll find a package with the description "Allows SQL Server Compact 4.0 to be used with Entity Framework." Install this package.

类似于以下内容的元素将被插入到您的 web.config 中:

An element similar to the following will be inserted in your web.config:

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
    <parameters>
      <parameter value="System.Data.SqlServerCe.4.0" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework>

这篇关于无法找到请求的 .Net Framework 数据提供程序.它可能没有安装.- 在遵循 mvc3 asp.net 教程时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:无法找到请求的 .Net Framework 数据提供程序.它可能没有安装.- 在遵循 mvc3 asp.net 教程时

基础教程推荐