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

给你一囗甜甜゛ 提交于 2019-11-29 22:03:53

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.

You need to install Microsoft SQL Server Compact 4.0.

blowdart

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.)

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

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.

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.

  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.

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.

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

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

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>

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.

Mạnh Viết Đặng

Try this:

<add name="MovieDBContext"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Movies.sdf;User Instance=true"
     providerName="System.Data.SqlClient" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!