0

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 SqlMetal-generated datacontext classes in some way? Or can it be done simpler?

Community
  • 1
  • 1
bretddog
  • 5,411
  • 11
  • 63
  • 111

1 Answers1

0

Ok, I added this attribute to all properties in the entity classes. Not sure if that's the best way though.

UpdateCheck:=UpdateCheck.Never
bretddog
  • 5,411
  • 11
  • 63
  • 111