1 2

MVC中异常: An exception of type 'System.Data.ProviderIncompatibleException' occurred in EntityFramework.dll的一种解决办法

MVC中异常: An exception of type 'System.Data.ProviderIncompatibleException' occurred in EntityFramework.dll的一种解决办法

今天在调试MVC的例子的时候,总是出错(An exception of type 'System.Data.ProviderIncompatibleException' occurred in EntityFramework.dll but was not handled in user code)。在这里报Exception.我改了好久connectionString,还是不能解决问题。

        public ActionResult Index()
        {
            return View(db.Movies.ToList());
        }

终于发现这个帖子的最后,我也加上了这个基类初始化方法: http://q.cnblogs.com/q/48825/。果然运行正常了。

 

1
2
3
4
5
6
7
8
9
public class MovieDBContext : DbContext
{
    public MovieDBContext()
        base("DefaultConnection")
    {
         
    }
    public DbSet<Movie> Movies {get;set;}
}
posted @ 2017-08-10 10:40  大海的泡沫  阅读(310)  评论(0编辑  收藏  举报
1 2