locked
Unique Index - not working in LightSwitch 2013 RTM Silverlight RRS feed

  • Question

  • Unique Index was working in LS 2012 and not any more in LS 2013. Something mush have changed.

    I have a table where it has a unique index made of four fields.

    Each of these fields has "Include in Unique Index" ticked.

    The new LS 2013 will not compile anymore saying that there are some data issues.

    When I removed the records, then it compiles ok.

    Temporarily I decided to remove this index to have it compiled.

    Is there anyone sharing the same issue?

    Friday, October 18, 2013 5:53 AM

All replies

  • It looks to be working fine. VS2013 RTM seems to force a CREATE UNIQUE INDEX on the database table. Was VS2012 and earlier not enforcing data integrity onto existing data?

    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.


    • Edited by Xpert360 Friday, October 18, 2013 2:58 PM
    Friday, October 18, 2013 2:58 PM
  • I can confirm that fields flagged as "Include in unique index" were combined into a single unique key constraint in VS2012. In VS2013 they are now created as single field unique keys.

    Friday, October 18, 2013 3:13 PM
  • In which case that is going to be a problem...

    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    Friday, October 18, 2013 4:18 PM
  • Saturday, October 19, 2013 9:19 PM
  • Hi to all

    ADefwebserver, do not think it is the same problem, in fact is exactly what mf_falkao said.

    The curious thing is that if the thread open n connect site complains about correct behavior of LS found in the 2012 version, and from what I could understand the thread suggests that the behavior of the LS case over a field is flaged as unique in a same table is exactly that which we find in VS2013 RTM.

    I'm afraid that an intern at M$ have read the post and thought

    "Let me fix this"

    Victor Perez
    Sunday, October 20, 2013 1:45 AM
  • Victor,

    You are correct. The bug that was submitted in the Connect report is not the same exact issue; it only involves the same feature. I logged a bug yesterday when I saw this thread and the other thread. I'll make sure it gets routed to the correct team to investigate it.

    Also, we don't appreciate insults or putdowns. All it does is insight anger and detracts from meaningful conversation.


    Justin Anderson, LightSwitch Development Team

    • Proposed as answer by Angie Xu Monday, October 28, 2013 5:24 AM
    Sunday, October 20, 2013 8:35 AM
    Moderator
  • Not to detract from the issue in any way, but is it only me that never develops using the intrinsic database? Just curious, instinctively I use attached SQL Express db

    Ian Mac

    Sunday, October 20, 2013 10:50 AM
  • Hi Ian,

    People who are confident in manipulating databases have a tendency to use external databases, but it is quite a mix of users out there.

    On this issue there is a reasonable workaround. It is not going to stop using LightSwitch in VS2013, there is too much other good stuff!

    I know it is hard, but if Justin could give an indication of the approximate time scale for a fix then you can make your own judgment as to whether to use the workaround. If it will be a few weeks then the workaround looks like a sound option to me.

    I would estimate that you can put this in place in a few minutes for any project (I will add that our AIDE entity explorer views help by exporting metadata reports to Excel, a report on entity columns with 'include in unique index' - you could use a free trial to help with this workaround).

    The workaround is to not use the 'Include in Unique Index' option on entities in LightSwitch. Add a unique index in a script in a database project attached to the LightSwitch project.

    e.g.

    -- Unique index on Products
    CREATE UNIQUE NONCLUSTERED INDEX [Products_UniqueIndex] ON [dbo].[Products] 
    (
    	[Name] ASC,
    	[Color] ASC
    )
    GO
    

    Lightswitch runs the script and you get the correct data integrity rule applied.

    Once you have established this you can leave it in place.

    Cheers

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    Sunday, October 20, 2013 11:22 AM
  • Hi Dave,

    All very true.

    Which is why I wondered why Michael seemed to feel it was a showstopper (for him) as suggested in one of his tweets. Michael? Just curious!


    Ian Mac

    Sunday, October 20, 2013 1:40 PM
  • Hi Dave,

    All very true.

    Which is why I wondered why Michael seemed to feel it was a showstopper (for him) as suggested in one of his tweets. Michael? Just curious!


    Ian Mac


    Now that I see there is a workaround I took the Tweet down :)

    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    Sunday, October 20, 2013 1:51 PM
  • Victor,

    Você está correto. O bug que foi apresentado no relatório Connect não é o mesmo problema, que envolve apenas a mesma característica. Eu entrei um bug ontem, quando vi esta discussão eo outro fio. Eu vou ter certeza que é roteado para a equipe correta para investigá-la.

    Além disso, nós não apreciam insultos ou putdowns. Tudo que faz é introspecção raiva e diminui a conversa significativa.


    Justin Anderson, LightSwitch Development Team

    perfect Justin

    Good to know there team members observing the LS forumns.

    And by the way, live life with more good humor, you'll be happier


    Victor

    Sunday, October 20, 2013 2:36 PM
  • AND WHAT SHOULD I DO ?????


    rodrigo adelino

    Sunday, October 20, 2013 4:24 PM
  • Hi Justin,

    I posted the thread that you referred to and a few days ago, I submitted the same information via Connect.  Please let me know if I can provide any further information.  My postings included VS2012 and VS2013 samples that illustrate the problem.

    http://social.msdn.microsoft.com/Forums/en-US/fb9acd4a-43d5-4109-a623-b4c77f9694a5/urgent-vs2013-lightswitch-unique-constraint-bug-for-including-more-than-one-field?forum=lightswitch

    Thanks for passing the issue along to the development team! :)

    Mike



    Sunday, October 20, 2013 5:05 PM
  • I knew there had to be a logical explanation!

    I'm going to have to start playing with intrinsic db; this has taught me that I do not want to get caught out somewhere down the line; instinctively I've always gone down the 'design in SQL Express then attach' route, (I like to be able to view large parts of the 'model' i.e. through SQL SMS), so unless I screw up my own design, I'd never come across stuff like this.

    I think I've definitely had a subconscious mind-set that intrinsic is a 'toy' (for want of a better word) and have up to now avoided it; time to modify that attitude I think, if for nothing else than completeness!


    Ian Mac

    Sunday, October 20, 2013 5:28 PM
  • for sample in publish !!!

    Error 1  An exception occurred when deploying the database for the application.
    Could not deploy package.
    Error SQL72014: .Net SqlClient Data Provider: Msg 2627, Level 14, State 1, Line 28 Violation of UNIQUE KEY constraint 'UQ__tmp_ms_x__3199C5ED8F83A8A1'. Cannot insert duplicate key in object 'dbo.tmp_ms_xx_CidadesSet'. The duplicate key value is (AC).
    Error SQL72045: Script execution error.  The executed script:
    BEGIN TRANSACTION;

    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

    SET XACT_ABORT ON;

    CREATE TABLE [dbo].[tmp_ms_xx_CidadesSet] (
        [Id]           INT            IDENTITY (1, 1) NOT NULL,
        [RowVersion]   ROWVERSION     NOT NULL,
        [Cidade]       NVARCHAR (60)  DEFAULT '' NOT NULL,
        [Estado]       NVARCHAR (60)  DEFAULT '' NOT NULL,
        [Sigla]        NVARCHAR (2)   DEFAULT '' NOT NULL,
        [Pais]         NVARCHAR (60)  DEFAULT '' NOT NULL,
        [CodigoCidade] INT            DEFAULT 0 NOT NULL,
        [CodigoEstado] INT            DEFAULT 0 NOT NULL,
        [CodigoPais]   INT            DEFAULT 0 NOT NULL,
        [Log]          NVARCHAR (MAX) NULL,
        [LogData]      DATETIME       NULL,
        PRIMARY KEY CLUSTERED ([Id] ASC),
        UNIQUE NONCLUSTERED ([Cidade] ASC),
        UNIQUE NONCLUSTERED ([Sigla] ASC)
    );

    IF EXISTS (SELECT TOP 1 1
               FROM   [dbo].[CidadesSet])
        BEGIN
            SET IDENTITY_INSERT [dbo].[tmp_ms_xx_CidadesSet] ON;
            INSERT INTO [dbo].[tmp_ms_xx_CidadesS
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Publish\v2.1\Microsoft.LightSwitch.Publish.targets 1547 10


    rodrigo adelino

    Sunday, October 20, 2013 5:39 PM
  • Hi Rodrigo,

    You really need to consider rolling back to before VS2013 RTM, whether that was VS2013 RC or VS2012.

    Is that possible?

    The problem will get fixed.

    Another workaround is to roll-out the database schema changes manually, this is a deployment option. We have done that before. Are you able to move forward like this for a while?

    Cheers

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    Sunday, October 20, 2013 5:46 PM
  • actually, I'm keeping the production system in v2, to have confidence in migrating

    my idea is to be able to migrate everything with Visual Studio 2013 Released

    but I will follow up with tests

    people, do not lose focus of the application for businesses

    I was very pleased with this latest version and I'm excited to complete the migration, was just that.


    thanks to all

    rodrigo adelino

    Sunday, October 20, 2013 7:23 PM
  • any news ???

    rodrigo adelino

    Wednesday, October 23, 2013 7:18 PM
  • I haven't heard anything...  At this time, we are continuing to work with VS2012...
    Wednesday, October 23, 2013 7:28 PM
  • Hello

    Is there any official update on this? I am considering reverting to VS2012 as well. I understand there is a workaround.

    Cheers

    Wednesday, February 19, 2014 9:01 PM