Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 &引用;无法修改该列[column name=id]。”;何时插入一条记录_Windows Phone 7_Sql Server Ce_Datacontext - Fatal编程技术网

Windows phone 7 &引用;无法修改该列[column name=id]。”;何时插入一条记录

Windows phone 7 &引用;无法修改该列[column name=id]。”;何时插入一条记录,windows-phone-7,sql-server-ce,datacontext,Windows Phone 7,Sql Server Ce,Datacontext,我已经在WindowsPhone7平台上创建了一个数据库。表中的一个定义如下 [Table] public class Playlist : BaseTable { // Define ID: private field, public property, and database column. private int _id; [Column(DbType = "INT NOT NULL IDENTITY", IsDbGenerated = false, CanBe

我已经在WindowsPhone7平台上创建了一个数据库。表中的一个定义如下

[Table]
public class Playlist : BaseTable
{
    // Define ID: private field, public property, and database column.
    private int _id;

    [Column(DbType = "INT NOT NULL IDENTITY", IsDbGenerated = false, CanBeNull=false, IsPrimaryKey = true)]
    public int Id
    {
        get { return _id; }
        set
        {
            NotifyPropertyChanging("PlaylistId");
            _id = value;
            NotifyPropertyChanged("PlaylistId");
        }
    }
    // some other field
    //.......
}

我不希望字段“id”由db生成,因此“IsDbGenerated=false”,但我在插入一条记录时遇到了一个异常: db.Playlists.InsertOnSubmit(新播放列表{Id=(int)DefalutPlaylist.Default,Name=“Default Playlist”,Group=0,Type=0})

它说“该列无法修改[column name=id]”

谁能帮我…

在DbType中删除“一致性”值,如下所示:

[Column(DbType = "INT NOT NULL", IsDbGenerated = false, CanBeNull=false, IsPrimaryKey = true)]
Cheers

在DbType中删除“一致性”值,如下所示:

[Column(DbType = "INT NOT NULL", IsDbGenerated = false, CanBeNull=false, IsPrimaryKey = true)]

干杯

这在WP8中对我不起作用,我仍然得到这个例外。。。有什么想法吗?这在WP8中对我不起作用,我仍然得到这个例外。。。有什么想法吗?