首页 > Web开发 > 详细

MVC初学 - Entitytype has no key defined

时间:2015-08-05 10:06:04      阅读:264      评论:0      收藏:0      [点我收藏+]

问题:

entitytype has no key defined

 

Solution:

  1. 增加引用
  2. 增加关键字[Key]
  using System.ComponentModel.DataAnnotations;

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ContactsID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
        [Key]
        public int ContactsID
        {
            get
            {
                return this._ContactsID;
            }
            set
            {
                if ((this._ContactsID != value))
                {
                    this.OnContactsIDChanging(value);
                    this.SendPropertyChanging();
                    this._ContactsID = value;
                    this.SendPropertyChanged("ContactsID");
                    this.OnContactsIDChanged();
                }
            }
        }

 

MVC初学 - Entitytype has no key defined

原文:http://www.cnblogs.com/zero530/p/4703838.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!