Linq InsertOnSubmit not added to changeset

Applies to How to debug linq for InsertOnSubmit sql statement?

I Run the following bit of code:

db.DBUsers.InsertOnSubmit(new DBUser
    {
        Id = id,
        BrandCode3 = brandCode3.ToLower(),
        LoweredUsername = username.ToLower(),
        Username = username,
        CreationDate = date,
        Salt = salt,
        Password = SecurityService.CreateMD5Hash(salt + password),
        PasswordQuestion = passwordQuestion,
        PasswordAnswer = passwordAnswer,
        Comment = comment,
        Email = email,
        IsApproved = isApproved,
        LastPasswordChangedDate = date,
        FailedPasswordAnswerAttemptCount = 0,
        FailedPasswordAnswerAttemptWindowStart = date,
        IsLockedOut = false,
        IsOnLine = false,
        LastActivityDate = date
    }
);
db.SubmitChanges();

UPDATE
Here are the attributes for the primary key:

[Column(Storage="_Id", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
public System.Guid Id

I noticed that the Auto-sync property is set to Never in the properties window. I guess it should be OnInsert. Gonna check it out.

Right before I call the subtitle, I check the changeset and it doesn’t show insert, update or delete ... The SQL profiler shows that no query has been sent, adding db.Log shows that no action is being performed.
Why is nothing filed?

+3
5

, L2S? , " ", true.

0

ObjectTracking?

0

Linq , . .

[Column(Storage="_Id", AutoSync=AutoSync.OnInsert,
DbType="Int NOT NULL IDENTITY",
IsPrimaryKey=true, IsDbGenerated=true, UpdateCheck=UpdateCheck.Never)]

:

[Column(Storage="_Ts", AutoSync=AutoSync.Always, DbType="rowversion NOT NULL",
CanBeNull=false, IsDbGenerated=true, IsVersion=true, 
UpdateCheck=UpdateCheck.Never)]

public System.Data.Linq.Binary Ts

0

, . DBUser DBML ( DBUser2), , . , . . , " " DBML "/" . SqlMetal , .

0

Guid Id , Linq To Sql, , .

In your example, it looks like you are assigning it in your application, so it might not apply.

0
source

Source: https://habr.com/ru/post/1721686/


All Articles