zoukankan      html  css  js  c++  java
  • 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类

    • Solution Explorer,右击Model文件夹, 并选择Add -> Class
    • 在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 }
    • 配置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, 选择以下选项:

    • Controller name: MoviesController
    • Template: Controller with read/write actions and views, using Entity Framework.
    • Model class: Movie(MvcMovie.Models)
    • Data context class: MovieDBContext(MvcMovie.Models)

        解决方法:

              打开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>


             

      

  • 相关阅读:
    c# ThreadPool 判断子线程全部执行完毕的四种方法
    很多人都爱玩的lol..
    Go 的位操作
    wrk压测工具
    Go函数作为值与类型
    家用PC发展设想
    开车的烦恼
    一款一体机的设想
    nodejs开发环境的搭建
    Python网页抓取程序(续)
  • 原文地址:https://www.cnblogs.com/mystar/p/2377415.html
Copyright © 2011-2022 走看看