开发者

What causes this Member AutoSync failure?

I have this table:

create table dbo.NotificationsIn
(
    NotificationID varchar(18) primary key,
    ArrivalTime datetime not null default getdate()
)

I insert to it like this:

public void InsertNotification(NotificationsIn notification)
{
    db.NotificationsIns.InsertOnSubmit(notification);
    db.SubmitChanges();
}

where db is a LINQ DataContext.

I get the following exception after I insert a new record:

System.InvalidOperationException: Member AutoSync failure. For members to be Auto-Synced after insert, the type must either have an auto-generated identity, or a key that is not modified by the database after insert.

In the dbml, I have set the ArrivalTime property Auto开发者_如何学PythonGenerated = True and Auto-Sync = OnInsert. I have also tried Auto-Sync = Never, but the result is the same.

Any idea why I am getting this exception? Thank you.


You have not provided your database layer information.
The simplest solution is to make the NotificationID column an Identity one. This should help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜