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/。果然运行正常了。

 

    public class MovieDBContext : DbContext
    {
        public MovieDBContext()
            : base("DefaultConnection")
        { 
            
        }
        public DbSet<Movie> Movies {get;set;} 
    }

 

posted @ 2014-07-15 16:02  simonzhang  阅读(2479)  评论(0编辑  收藏  举报