请问下Mvc 3.0一个问题
这是前端调用
public ViewResult Index()
{
DataRecord dr = new DataRecord();
var aa = from bb in dr.Table<Charisma_User>()
where bb.Enabled
select bb;
//执行到这里的时候报错The entity type Charisma_User is not part of the model for the current context.
return View();
}
这是DataRecord构造
public class DataRecord : DbContext
{
private static DbContext _mdbContext;
public DataRecord()
: base("name=SqlConnection")
{
}
public DbSet<TEntity> Table<TEntity>()
where TEntity : class
{
return base.Set<TEntity>();
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
这里是Web.Config配置
<connectionStrings>
<add name="SqlConnection"
connectionString="Data Source=.;Initial Catalog=CeShi;uid=sa;pwd=sa;"
providerName="System.Data.SqlClient" />
</connectionStrings>
哪位大侠知道怎么解决报错的问题~~! --------------------编程问答-------------------- dbContext中没有Charisma_User类型。 --------------------编程问答-------------------- 我代码里面已经设置了啊
补充:.NET技术 , .NET Framework