无法加载指定的元数据资源,posgressql和entityframework

时间:2018-09-13 13:40:20

标签: postgresql entity-framework

我使用实体框架和PostgreSQL视图映射视图,但是我得到了 无法加载指定的元数据资源错误,

这是我在做什么:

 public class Custumers
{
    [Table("v_at_customers", Schema = "zd")]
    public class Customer
    {
        [Key]
        [Column("customer_id")]
        public int customer_id { get; set; }
        public string organization { get; set; }

    }
}

}

DbContext:

 public partial class db_Entities : DbContext
    {
    public db_Entities()
        : base("name=LTW")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }
    public DbSet<Customer> Customer { get; set; }
    }

这是我在控制器中得到错误的地方:

 db_Entities dt = new db_Entities();


        var s=(from t in dt.Customer
              select new 
              {

               Customeress=dt.customer_id

              }).Take(5);

1 个答案:

答案 0 :(得分:0)

我用黄色标记了您需要注意的地方

使用包:

enter image description here

配置文件:

enter image description here

dbcontext:

enter image description here

结果:

enter image description here