0

I'm having error with the column Id cannot contain null values but i set to true on IsDbGenerated. what am i doing wrong?

private int id;
[Column(IsPrimaryKey=true, CanBeNull=false, DbType="int", IsDbGenerated=true)]
public int Id
{
    get { return id; }
    set
    {
        if (id != value)
        {
            id = value;
            RaisePropertyChanged("Id");
        }
    }
}
4

1 回答 1

0

尝试这个

private int id;
    [Column(IsPrimaryKey=true, IsDbGenerated=true, DbType="INT NOT NULL IDENTITY", CanBeNull=false, AutoSync=AutoSync.OnInsert)]
    public int Id
    {
        get { return id; }
        set 
        {
            if (id != value)
            {
                NotifyPropertyChanging("Id");
                id = value;
                NotifyPropertyChanged("Id");
            }
        }
    }
于 2014-03-30T17:25:37.513 回答