首页新闻找找看学习计划

mvc3+EF5.0新建Control时报错,错误详情如下。

0
悬赏园豆:100 [已关闭问题] 关闭于 2013-07-03 10:04

在新建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=&quot;Data Source=192.168.0.16\SQL2005;Initial Catalog=db_present;Persist Security Info=True;User ID=db_present;Password=db_present;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"  />
  <!--<add name="db_presentEntities"     providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=Present;uid=sa;pwd=sasa" />-->
</connectionStrings>

请问下该错误该如何处理呢?

腿毛飞扬的主页 腿毛飞扬 | 菜鸟二级 | 园豆:204
提问于:2013-07-02 11:33
< >
分享
所有回答(1)
0
  <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>();
        }
腿毛飞扬 | 园豆:204 (菜鸟二级) | 2013-07-03 10:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册