Using: VS2008, Sql CE 3.5.
When I try to save an entity from a detached context, i'm not able to. And instead have to map each property.
Public Sub Save(ByVal user As Users)
Dim ctx As New TestDB(connection)
Dim q = (From n In ctx.Users Where user.Id = id Select n).Single
q.MapData(user)
' ctx.Users.Attach(user, q) ' Does not work
' ctx.Users.Attach(user, True) ' Does not work
End If
ctx.SubmitChanges()
It's indicated that turning off optimistic concurrency check will avoid this problem. (As answer here: Entity attachment issues in LINQ).
But how do I turn that off? Do I manually have to edit the SqlM开发者_JAVA技巧etal-generated datacontext classes in some way? Or can it be done simpler?
Ok, I added this attribute to all properties in the entity classes. Not sure if that's the best way though.
UpdateCheck:=UpdateCheck.Never
精彩评论