When you encounter this problem when learning MVC3.0, the English version will prompt the following error: not find request. net Framework Data Provider, maybe not installed. chinese version prompt: the request cannot be found. net FrameWork Data Provider, which may not be installed.
Steps to reproduce this problem:
1. Add Model class
O In Solution Explorer, right-click the Model folder and choose Add-> Class
O Add the following five attributes to the Movie class and add the MovieDBContext class.
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 configure Config and add the following string to the connectionStrings element.
View Code
1 <add name = "MovieDBContext" connectionString = "Data Source = | DataDirectory | Movies. sdf" providerName = "System. Data. SqlServerCe.4.0"/>
2. Right-click the Controllers folder and create a new MoviesController. cs. Select the following options:
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)
Solution:
O Install 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 not available after installation:
Open C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727 \ CONFIG \ machine. copy the content under the DbProviderFactories node to replace C: \ WINDOWS \ Microsoft. NET \ Framework \ v4.0.30319 \ Config \ machine. the corresponding location in 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>
From the string of qinyun