添加控制器错误无法检索元数据 [英] Add controller error unable to retrieve metadata
本文介绍了添加控制器错误无法检索元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的MVC 4应用在VS2012中添加控制器这一形象:
I want to add controller in my MVC 4 application in VS2012 as this image:
型号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace MvcDemo.Models
{
public class MovieDB
{
public int ID { get; set; }
public string Title { get; set; }
public string Director { get; set; }
public DateTime Date { get; set; }
}
public class MovieDBContext : DbContext
{
public DbSet<MovieDB> Movies { get; set; }
}
}
连接字符串:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MvcDemo-20130315191956;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MvcDemo-20130315191956.mdf"
providerName="System.Data.SqlClient" />
<add name="MovieDBContext"
connectionString="Data Source=|DataDirectory|\Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>
点击添加后,出现此错误:
After clicking "add", this error occurs:
unable to retrieve metadata for 'MvcDDemo.Models.MovieDB'.Using the
same DbCompiledModel to create contexts against different type of
database servers is not supported.instead,create a
separate DbCompiledModel for each type of server being used.
任何建议?
推荐答案
在的Web.config
,设置第二个的providerName
同第一的providerName
并创建控制器后,撤消!
In Web.config
, set second providerName
same as first providerName
and after creating controller, undo that!
从:这里 的
这篇关于添加控制器错误无法检索元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文