locked
rowguidcol = true on SQL Express is false in sqlce RRS feed

  • Question

  • Hi everybody this is my first post here and since a few days I have the following problem:

    If I define a Column as Uniqueidentifier,Primary Key,IsRowGuid = true in SQLServerExpress 2005 and then let VS2008 (Sp1 with .Net 3.5 SP1) generate the localDatabaseCache the column has in the sqlce the property "IsRowGuid" = false .

    That's the error and i cannot change it (in Edit Table Schema) in the VS Server Explorer as VS says that change tracking is activated and DDL Commands are not allowed.
    My workmate also gets the same error

    Any ideas how to change that?
    • Moved by Hengzhe Li Friday, April 22, 2011 2:52 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, June 16, 2009 1:27 PM

Answers

  • Hi,

    RowGuid columns are synced to local database but ROWGUID property is not synced. Why do you need RowGuid property set to true?? You may assign new guid value by using NewId function as default value or binding property.

    Sample:
    CREATE TABLE [dbo].[Test](
        [id] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
        [desc] [nchar](10) NULL,
     CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED 
    (
        [id] ASC
    )) ON [PRIMARY]
     
    GO
     
    ALTER TABLE [dbo].[Test] ADD  CONSTRAINT [DF_test_id]  DEFAULT (newid()) FOR [id]
    GO
     

    Cheers,

    José Miguel Torres
    Friday, June 19, 2009 2:34 PM

All replies

  • Hi,

    RowGuid columns are synced to local database but ROWGUID property is not synced. Why do you need RowGuid property set to true?? You may assign new guid value by using NewId function as default value or binding property.

    Sample:
    CREATE TABLE [dbo].[Test](
        [id] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
        [desc] [nchar](10) NULL,
     CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED 
    (
        [id] ASC
    )) ON [PRIMARY]
     
    GO
     
    ALTER TABLE [dbo].[Test] ADD  CONSTRAINT [DF_test_id]  DEFAULT (newid()) FOR [id]
    GO
     

    Cheers,

    José Miguel Torres
    Friday, June 19, 2009 2:34 PM
  • Hello José,
    I know I can set the constraint locally with SQL but only on a table that is on synchronized. Otherwise I get the obove mentioned error.
    I wanted the id to be set automatically as I think it's the best way to compute "Primary Keys".

    At the moment I set the GUID id via c#
    System.Guid.NewGuid()
     into the id Field generated from EF.

    I'm wondering if this is BestPractice?
    but I haven't found any other way.
    My very first try was with integer as a Primary Key for ids but the sync Framework does not support serverSide generated Keys ( http://stackoverflow.com/questions/648449/server-generated-keys-and-server-generated-values-are-not-supported-by-sql-server ) 
    Friday, June 19, 2009 5:05 PM
  • Hi,

    The limitation that you mentioned is in the Entity framework but not Sync framework. You should be able to use integer as a primary key of your table if you do not code your sync app on top of Entity framework.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Friday, June 26, 2009 5:35 PM
    Moderator
  • Hi Dong,
    thanks for your reply. I need to connect with the EntityFramework to the sqlce Database and in this combination there is no support for server generated keys see also http://technet.microsoft.com/en-us/library/cc835494.aspx.

    José pointed out that rowguidcol==false in sqlce is wanted.
    I'm now setting the id in the sqlce for new records via System.Guid.NewGuid() that works fine.

    Greetings Martin
    Friday, June 26, 2009 10:22 PM