Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find the requested .Net Framework Data Provider. It may not be installed. - when following mvc3 asp.net tutorial

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

like image 919
michelle Avatar asked Jul 28 '11 20:07

michelle


4 Answers

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>
like image 102
vitaminjeff Avatar answered Oct 28 '22 21:10

vitaminjeff


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

like image 41
Sundar Avatar answered Oct 28 '22 21:10

Sundar


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.

like image 10
Atif Avatar answered Oct 28 '22 23:10

Atif


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

like image 1
Malek Aitouche Avatar answered Oct 28 '22 21:10

Malek Aitouche