在新建Control的时候 报错信息是:无法检索Present.Models.ManagerModel
ManagerModel代码如下
namespace present.Models { public class ManagerModel { public ManagerModel() { } [Key] [DisplayName("编号")] public int manager_id { get; set; } [DisplayName("姓名")] public string manager_name { get; set; } [DisplayName("邮箱")] public string manager_email { get; set; } [DisplayName("账号")] public string manager_uid { get; set; } [DisplayName("密码")] public string manager_pwd { get; set; } [DisplayName("添加时间")] public DateTime add_time { get; set; } [DisplayName("是否启用")] public bool is_open { get; set; } [DisplayName("关闭时间")] public DateTime close_time { get; set; } } }
DataContext如下:
namespace present.Models { public class DataContext : DbContext { private readonly static string Connection_String = "name=db_presentEntities"; public DbSet<ManagerModel> Manager { get; set; } public DataContext() : base(Connection_String) { }//不写这个 默认的就是SchoolContext protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约 modelBuilder.Conventions.Remove<IncludeMetadataConvention>();//防止黑幕交易 要不然每次都要访问 EdmMetadata这个表 } } }
WECONFIG配置如下
<connectionStrings> <add name="db_presentEntities" connectionString="metadata=res://*/Models.Entity.Db_Present.csdl|res://*/Models.Entity.Db_Present.ssdl|res://*/Models.Entity.Db_Present.msl;provider=System.Data.SqlClient;provider connection string="Data Source=192.168.0.16\SQL2005;Initial Catalog=db_present;Persist Security Info=True;User ID=db_present;Password=db_present;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> <!--<add name="db_presentEntities" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=Present;uid=sa;pwd=sasa" />--> </connectionStrings>
请问下该错误该如何处理呢?
<connectionStrings> <add name="db_presentEntities" providerName="System.Data.SqlClient" connectionString="Data Source=192.168.0.16\SQL2005;database=db_present;uid=db_present;pwd=db_present"/> </connectionStrings>
datacontext改下
protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }