1

On inserting a record:

        Poster_ratings prItem = new Poster_ratings
        {
            poster_id = posterId,
            rating = rating,
            email = email,
            name = name,
            event_id = eventId,
            id = GetNextID()
        };

        entity.AddToPoster_ratings(prItem);
        entity.SaveChanges();

I get the error that server-generated values are not supported..

I'm using Sql compact 3.5 (highest version supported by MS Sync Framework). I already read this post and set 'setStoreGeneratedPattern' to none for this table but this didn't help either, I keep getting the same error..What should I do to resolve this?

Greets & Thanks in advance

Community
  • 1
  • 1
Daan
  • 466
  • 1
  • 8
  • 21
  • [tried to change type?](http://stackoverflow.com/questions/648449/server-generated-keys-and-server-generated-values-are-not-supported-by-sql-serve) – Renatas M. Apr 05 '12 at 08:13
  • Currently used type for auto increment primary key column (id) is int32, what type should I change it to? – Daan Apr 05 '12 at 08:16
  • 1
    try uniqueidentifier as pointed in linked answer. – Renatas M. Apr 05 '12 at 08:20
  • My guess is that this would give the same error..And also I can't really change the type, since my sql ce database is build up based on another sql server (using MS sync framework). – Daan Apr 05 '12 at 08:28
  • 1
    Sounds like a fundamental flaw in the design. I'm extremely surprised anyone would want to use an int for an identity column, especially when dealing with and sync'ing. – Erik Philips Apr 05 '12 at 09:28

1 Answers1

1

have a look at this: Server-generated keys and server-generated values are not supported by SQL Server Compact

as Erik pointed above, using identity values for your PKs when synchronizing is problematic. If two or more clients inserted rows and got the same autogenerated number via identity, you will get PK conflicts when you sync them to the server.

here's a link for choosing a PK in Sync Framework: Selecting an Appropriate Primary Key for a Distributed Environment

Community
  • 1
  • 1
JuneT
  • 7,840
  • 2
  • 15
  • 14