码迷,mamicode.com
首页 > Web开发 > 详细

MVC初学 - Entitytype has no key defined

时间:2015-08-05 10:07:05      阅读:176      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!