VS 2008, SqlCe 3.5
I'm trying to learn EntityFramework, but can't get the basic Insert and update to work. When I include the SqlCe database (.sdf) a wizard creates the Test.edmx/designer.vb file. From that I create my datacontext, like below. The table name is Users.
The syntax of my entity classes seems a bit different from examples on the web. That's a bit confusing, and I don't know why this is. Below I show two different Insert methods, both of which gives exceptions on the .SaveChanges line:
An error occurred while updating the entries. See the InnerException for details.
{"Server-generated keys and server-generated values are not supported by SQL Server Compact."}
Also the Update method I have really no idea what to write in the missing part.. Would be very glad for some assistance on these issues...
Public Sub Insert(ByVal user As Users)
Dim ctx As New TestDBEntities1(connection)
ctx.Users.Context.AddObject("Users", user)
ctx.Users.Context.SaveChanges()
End Sub
Public Sub Insert(ByVal user As Users)
Dim ctx As New TestDBEntities1(connection)
ctx.AddToUsers(user)
ctx.SaveChanges()
End Sub
Public Sub Update(ByVal user As Users)
Dim ctx As New TestDBEntities1(connection)
Dim q = (From n In ctx.Users Where n.Id = user.Id Select n).Single
' How to update ??
ctx.SaveChanges()
End Sub