我遇到错误,列Id不能包含空值,但我在IsDbGenerated上设置为true。我做错了什么?
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");
}
}
}
答案 0 :(得分: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");
}
}
}