locked
BUG: DEFAULT NEWID() not recognized when adding a column to a table RRS feed

  • General discussion

  • I had a table defined in SQL Server to use an IDENTITY as a PRIMARY KEY. I needed to change this to add a column of type UNIQUEIDENTIFIER and use that as the PRIMARY KEY. So I changed the SQL CREATE to the following code:

        "QuoteID" uniqueidentifier default newid()
            not null primary key,
        "QuoteSequence" int identity(60000, 1)
            not null,

    I use very similar code in several other tables but they have been that way since I imported the project from Lightswitch V1.

    Back in VS2012, I updated my Data Source and ran the app. But every new Quote generated a QuoteID of {00000000-0000-0000-0000-000000000000}. Since it is a PRIMARY KEY, I was only able to add one Quote.

    In trying to solve this problem, I came across the following article. Upon inspecting Service.lsml, I found that the SsdlProperty for QuoteID was missing the line

    StoreGeneratedPattern="Identity"

    Adding that line fixed the problem.

    Friday, July 27, 2012 3:35 PM

All replies

  • Bugs are reported on the LightSwitch Connect website, not in the forums. Just dumping a bug here is very likely to be missed.

    If you have questions about if others have run into similar problems, how to solve them, or offer up solutions, feel free to start threads about it in the forums.

    I encourage you to submit a bug report on the Connect site so that it gets routed to the proper team for investigation.


    Justin Anderson, LightSwitch Development Team

    Monday, July 30, 2012 6:35 AM
    Moderator
  • Understood. Bug filed: https://connect.microsoft.com/VisualStudio/feedback/details/756063/default-newid-not-recognized-when-adding-a-column-to-a-table#tabs

    I also added the workaround.

    Monday, July 30, 2012 12:37 PM