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

发布于 2024-11-27 00:18:36 字数 2498 浏览 0 评论 0 原文

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

确切错误:

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:\Users\Michelle\documents\visual studio 2010\Projects\MusicApplication\MusicApplication\Controllers\StoreController.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 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:

Exact error:

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:\Users\Michelle\documents\visual studio 2010\Projects\MusicApplication\MusicApplication\Controllers\StoreController.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: 

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

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

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

发布评论

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

评论(8

甜中书 2024-12-04 00:18:36

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

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

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

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

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

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

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

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.

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>
帅的被狗咬 2024-12-04 00:18:36

我有同样的问题。我检查了 C:\Windows\Assembly 中 System.Data.SqlServerCe 的版本。当时是 3.5.1.0。所以我从下面的链接(x86)安装了版本 4.0.0 并且工作正常。

http://www.microsoft.com/download/en/details.aspx?id=17876< /a>

I had the same issue. I checked the version of System.Data.SqlServerCe in C:\Windows\assembly. It was 3.5.1.0. So I installed version 4.0.0 from below link (x86) and works fine.

http://www.microsoft.com/download/en/details.aspx?id=17876

盗琴音 2024-12-04 00:18:36

将这些行添加到您的 web.config 文件中:

<system.data>
    <DbProviderFactories>
               <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data,  Version=6.6.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
    </DbProviderFactories>
</system.data>

将您的提供程序从 MySQL 更改为 SQL Server 或您要连接到的任何数据库提供程序。

Add these lines to your web.config file:

<system.data>
    <DbProviderFactories>
               <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data,  Version=6.6.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
    </DbProviderFactories>
</system.data>

Change your provider from MySQL to SQL Server or whatever database provider you are connecting to.

木緿 2024-12-04 00:18:36

此错误主要是由于处理器架构与安装的框架 ei x86 vs x64 不兼容
解决办法:
转到解决方案资源管理器>项目属性>编译选项卡>高级编译选项
在那里你必须将目标CPU从X64更改为X86
保存新设置并重新编译您的解决方案。
我尝试了一下,效果非常好。
希望这会对您有所帮助。
马利克

This error is mainly due to processor architecture incompatibility with Framework installed ei x86 vs x64
The solution:
Go to solution explorer>project properties>Compile tab>Advanced Compile Options
There you have to change Target CPU from X64 to X86
Save new setting and recompile your solution.
I tried it and it worked very fine.
Hope this will help you out.
Malek

攒眉千度 2024-12-04 00:18:36

我在 WCF 服务上的 SqlClient 上遇到了类似的问题。
我的解决方案是将这些行放入客户端 app.config

  <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>

希望它对某人有帮助..

I had a similer problem with SqlClient on WCF service.
My solution was to put that lines in client app.config

  <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>

Hopes it helps for someone..

你不是我要的菜∠ 2024-12-04 00:18:36

就我而言,该问题是由 SQL 数据库的连接问题引起的。我只是从设计视图断开 SQL 数据源,然后重新连接。我已经恢复并运行了。希望这对每个人都有效。

In my case, the issue was caused by a connection problem to the SQL database. I just disconnected and then reconnected the SQL datasource from the design view. I am back up and running. Hope this works for everyone.

若无相欠,怎会相见 2024-12-04 00:18:36

在遵循第 4 部分中的 MvcMusicStore 教程时,我也有同样的情况,并将给定的连接字符串替换为:

add name="MusicStoreEntities"
connectionString =“数据源=。\ SQLEXPRESS;集成安全性= SSPI;数据库= MvcMusicStore;用户ID = sa;密码=”
ProviderName =“System.Data.SqlClient”/>

这对我有用。

I had the same when following MvcMusicStore Tutorial in Part 4 and replaced the given connection String with this:

add name="MusicStoreEntities"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;database=MvcMusicStore;User ID=sa;password="
providerName="System.Data.SqlClient"/>

It worked for me.

一人独醉 2024-12-04 00:18:36

这发生在我身上,因为我创建了一个新项目,该项目试图使用 System.Web.Providers 来获取成员资格。我的数据库和应用程序设置为使用 System.Web.Security.SqlMembershipProvider 来代替。我必须更新提供程序和连接字符串(因为该提供程序似乎有一些奇怪的连接字符串要求)才能使其正常工作。

This happened to me because I created a new project which was trying to use System.Web.Providers DefaultMembershipProvider for membership. My DB and application was set up to use System.Web.Security.SqlMembershipProvider instead. I had to update the provider and connection string (since this provider seems to have some weird connection string requirements) to get it working.

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