Not find request .Net FrameWork Data Provider, may be not installed
在学习MVC3.0遇到这样的问题, 在英文版本上会提示这样的错误: not find request .Net Framework Data Provider, maybe not installed. 中文版本的提示: 找不到请求的.Net FrameWork Data Provider, 可能没有安装.
重现这个问题的步骤:
1. 添加Model类
o 在Solution Explorer,右击Model文件夹, 并选择Add -> Class
o 在Movie类中添加以下5个属性 并且添加MovieDBContext 类
View Code
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Web;
5 using System.Data.Entity;
6
7 namespace MvcMovie.Models
8 {
9 public class Movie
10 {
11 public int ID { get; set; }
12 public string Title { get; set; }
13 public DateTime ReleaseDate { get; set; }
14 public string Genre { get; set; }
15 public decimal Price { get; set; }
16 }
17
18 public class MovieDBContext : DbContext
19 {
20 public DbSet<Movie> Movies { get; set; }
21 }
22 }
o 配置Config,并且添加以下string到connectionStrings元素里
View Code
1 <add name ="MovieDBContext" connectionString ="Data Source=|DataDirectory|Movies.sdf" providerName ="System.Data.SqlServerCe.4.0"/>
2. 右击Controllers 文件夹 并且创建一个新的MoviesController.cs, 选择以下选项:
o Controller name: MoviesController
o Template: Controller with read/write actions and views, using Entity Framework.
o Model class: Movie(MvcMovie.Models)
o Data context class: MovieDBContext(MvcMovie.Models)
解决方法:
o 安装SQL Server Compact 4.0(runtime + tools support)
ohttp://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=033cfb76-5382-44fb-bc7e-b3c8174832e2&displaylang=zh-cn
o 如果安装后还不可以:
打开C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config,复制DbProviderFactories节点下的内容替换C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config中的相应位置.
View Code
<DbProviderFactories> < add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> < add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> < add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> < /DbProviderFactories>
摘自 琴韵之弦
补充:Web开发 , ASP.Net ,