ASP.NET MVC 3 - Unable to find the requested .Net Framework Data Provider
Asked Answered
A

13

55

Background-info:

I'm using Microsoft Visual Web Developer 2010 Express.
Info about my (lack of) experience: the problem occured within the first tutorial that I'm trying to work through.

Some additional-info:

  • I'm comfortable with C#, Postgres, Rails (so MVC & Web-apps are not new to me)
  • I have no experience with ASP.NET or SQL Server

Problem Description:

I'm trying to following exactly the steps from the "Intro to ASP.NET MVC 3"-tutorial and I'm running into a problem at the first step from part 5 - Adding the MoviesController:

When I'm trying to add the "MoviesController" with the exact settings that are shown in the tutorial and click 'Add' I get the following error:

"Unable to retrieve metadata for MvcMovie.Models.Movie. Unable to find the requested .Net Framework Data Provider. It may not be installed."

Google gave a ton of results when searching for the phrase "Unable to find the requested .Net Framework Data Provider", but nothing has solved the problem so far.

What I've tried:

I think SQL-Server was not installed so I installed it from the Visual-Studio Express ISO- got an error then I've run a repair from the ISO and it claimed that all 15 points including SQL Server Express repair &.NET 4 Framework went through successfully.

I've run the The_.NET_Framework_Setup_Verification_Tool which succeeded for everything. http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx

After the mentioned (re-)installing & repairing I recreated the Project and followed every step as described in the tutorial and got the same error.

I found that I should look for DbProviderFactories in machine.config,

The root-Web.config of the Project has the following entries

  <connectionStrings>
    <add name="MovieDBContext"
     connectionString="Data Source=|DataDirectory|Movies.sdf"
     providerName="System.Data.SqlServerCe.4.0"/>

My machine config-file has only one DbProviderFactories entry:

<DbProviderFactories>
<add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/></DbProviderFactories>

then I found the following quote

"we have changed the way DbProviderFactories.GetFactoryClasses() determines the framework providers in VS2010. They are no longer listed in the machine.config file. "

from http://social.msdn.microsoft.com/Forums/en-ZA/adodotnetdataproviders/thread/d79129c4-ae05-4c45-8997-bd90f5765a3a

Question:

So perhaps this is the wrong direction and since I have no clue what to try next, what steps should I take to investigate & solve this problem?
Btw. I have postgres installed, so if using postgres instead of SQL-server would be an easy solution let me know. For my own projects I would want to use a different DB anyway (probably postgres), but for now I would just want to be able to get successfully through the first and seemingly simple tutorial I've tried.

Alanaalanah answered 28/6, 2011 at 14:58 Comment(4)
If only everyone defined their questions like this +1Mishear
thanks I appreciate the comment.Alanaalanah
I had the same exact problem, doing the same exact thing. Thanks.Immedicable
Try this link, this might help even more for you: https://mcmap.net/q/339188/-mvc3-unable-to-retrieve-metadata-for-my-model-class-when-i-want-to-accesse-model-data-from-controllerVogeley
B
56

I was having the same problem so I replaced

<add name="MovieDBContext"     connectionString="Data Source=|DataDirectory|Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>

with the following

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

And it worked enough to let me continue working. I too would also eventually learn how to make these kinds of applications work with mysql at some point, but for now this should at least help you continue with the tutorial.

Breathe answered 28/6, 2011 at 22:7 Comment(4)
This is not correct way to solve the problem. This is one type of pitch up work.Correct way to Install Microsoft SQL Server Compact 4.0.Stinker
fattyman's solution works. @Saroop Trivedi I already have SQL server compact 4.0 installed and I still get the above error.Dichy
I was able to finally get it working by using the original connection string, but adding a reference to "System.Data.SqlServerCe" (version 4.0, not 3.5).Brachiate
This answer could be a good workaround but as I experienced Installing Windows Server Ce match better ;)Sanguinary
D
42

You need to install Microsoft SQL Server Compact 4.0.

Direct answered 12/7, 2011 at 22:23 Comment(1)
This did not work for me, I already have Sql Server CE 4.0 installedAhders
K
7

If you look at the config you'll see that installing SQL Server was a red herring;

<add name="MovieDBContext"
 connectionString="Data Source=|DataDirectory|Movies.sdf"
 providerName="System.Data.SqlServerCe.4.0"/>

SqlServerCE is not, I'm afraid, full blown SQL Server, it's SQL Server Compact Edition. I would have thought that would have been installed with VS Express, however you can download the specific installers from here

I actually had both SQLServerCE and Express installed, but the tutorial used Compact Edition: One step within part 4 of the tutorial is to explicitly add the part you quoted to the Web.config. So this is a part of the web.config by intention.

But deleting this part from the web.config makes it possible to add the Controller in the way the tutorial described it. While this means no longer exactly following the tutorial, it's fine for me. (This results in the creation of an MvcMovie.Models.MovieDBContext database in SQL Server Express.)

Klusek answered 28/6, 2011 at 18:36 Comment(0)
D
1

Rebuilding the project wont catch config errors in the DBContext section... the build process does not walk through connections, so you can build all day and still bomb out. As suggested above, fix the config so the connection string matches MachineName/SQLInstanceName/DBName with the correct SQL config. Worked just fine by just modifying my web.config in my solution.

Divertissement answered 21/11, 2011 at 23:26 Comment(0)
A
1

http://forums.asp.net/t/1679349.aspx/1 CypressBender

Re: Unable to retrieve metadata for * Unable to find the requested .Net Framework Data Provider.... Aug 08, 2011 07:44 PM|LINK

I installed Microsoft SQL Server Compact 4.0, and that fixed the problem for me. http://www.microsoft.com/download/en/details.aspx?id=17876

Armitage answered 22/2, 2012 at 20:42 Comment(0)
O
1

I changed my SQL providerName="System.Data.SqlClient" in web.config , since I have SQL client as well as SQL compact installed on my system.

Ovary answered 27/4, 2012 at 20:29 Comment(0)
D
0
  1. Make sure that you build prior to adding the controller. If that doesn't work...
  2. Create a new project, create a new sql server database manually and see if you can connect to it. If not, then the problem is indeed in your sql server config on your machine. You can try going to postgres just be sure that the provider you choose has support for EF code first.
Desolation answered 28/6, 2011 at 15:52 Comment(0)
F
0

What I did was in order to overcome the first problem I put in Web.config the code:

 <add name="MovieDBContext"
     connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Movies.sdf;Integrated Security=True"
   providerName="System.Data.SqlClient"/>

Notice I am creating SQL CE 4 database, therefore the .sdf and not .mdf

Next, you should receive another connection errors on the page /Movies, so replace the above code with :

<add name="MovieDBContext"
     connectionString="Data Source=|DataDirectory|\Movies.sdf;"
   providerName="System.Data.SqlServerCe.4.0"  />

And you should be fine.

Fructiferous answered 15/11, 2012 at 16:10 Comment(1)
What could be the connection string for full version of SQL Server?Renn
A
0

I had a server. It ran windows updates. And a message waiting for restart was open. After restart it worked again.

Acrylonitrile answered 5/12, 2012 at 13:26 Comment(0)
C
0

Install Microsoft SQL Server Compact 4.0. The link for same is - http://www.microsoft.com/en-us/download/details.aspx?id=17876

Calida answered 7/3, 2013 at 21:34 Comment(0)
S
0

This worked for me, hope it helps

<add name="MovieDBContext"
     connectionString="Data Source=(local);Initial Catalog=Movies; Integrated Security=true;"    providerName="System.Data.SqlClient" />
</connectionStrings>
Smile answered 8/3, 2013 at 15:50 Comment(0)
L
0

After reading other discussions around the web I have found another method. If you do not add the connection string until after you have created the controller class, then it will work also. It kind of seems like a bug.

Leveret answered 21/3, 2013 at 12:19 Comment(0)
P
0

Try this:

<add name="MovieDBContext"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Movies.sdf;User Instance=true"
     providerName="System.Data.SqlClient" />
Practical answered 6/5, 2013 at 2:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.