locked
Newbie: Lightswitch 2012 -- no tables found in database RRS feed

  • Question

  • My test box has VS 2012 Ultimate, Update 2,  and Sql Server 2008 R2, SP3, installed. Started a new Lightswitch project (C#), selected "Attach to external Data Source". Selected "Database", entered required information, pressed Test Connection (was successful), the pressed OK. The next pane of the "Attach Data Source Wizard" displays "The selected database does not contain  any tables or views..." Actually, the database contains a single table (as shown by SSMS installed on this box). I'd appreciate any ideas you have about this.

    TIA,

    edm2


    • Edited by edm2 Monday, April 29, 2013 8:08 PM R2 edit
    Monday, April 29, 2013 4:28 PM

Answers

  • @edm2

    LightSwitch creates the EF model for you, so you don't have to worry about doing that in a LightSwitch application. I think what Huy was suggesting was trying to see if EF could attach to your table outside of LightSwitch, to rule LightSwitch out as the cause of the problem.

    Does your table have a primary key (preferably auto-incrementing Integer)? Without a unique ID field, LightSwitch won't display the table, or allow you to use it.


    Yann Duran
         - Co-Author of Pro Visual Studio LightSwitch 2011
         - Author of the  LightSwitch Central Blog

    FREE Download: Luminous Tools for LightSwitch
    (a Visual Studio productivity extension for LightSwitch)
     
    Click Mark as Answer, if someone's reply answers your question
    Click  Vote as Helpful, if someone's reply is helpful
     
    By doing this you'll help everyone find answers faster.

    • Marked as answer by edm2 Tuesday, April 30, 2013 9:52 PM
    Tuesday, April 30, 2013 12:39 PM
    Moderator

All replies

  • Hi,

    Since LightSwitch data layer uses Entity Framework when attaching to databases, it can only show tables that Entity Framework can attach to. You can follow the instruction on creating an .edmx file from an existing database here and see if Entity Framework can create an Entity Model from your database.

    Also, if you can post the schema of your table it would help, too.

    Best regards,
    Huy

    Tuesday, April 30, 2013 5:17 AM
  • Huy,

    I did not (knowingly) create an edmx file at all. I created the table under SSMS and expected LightSwitch to recognize it "out of the box". I understand your explanation but regard that behavior of LightSwitch as totally non-intuitive and not in keeping the "ease of use" I expected from the product. Let me read through the URL you posted. Thank you.

    edm2

    Tuesday, April 30, 2013 7:16 AM
  • @edm2

    LightSwitch creates the EF model for you, so you don't have to worry about doing that in a LightSwitch application. I think what Huy was suggesting was trying to see if EF could attach to your table outside of LightSwitch, to rule LightSwitch out as the cause of the problem.

    Does your table have a primary key (preferably auto-incrementing Integer)? Without a unique ID field, LightSwitch won't display the table, or allow you to use it.


    Yann Duran
         - Co-Author of Pro Visual Studio LightSwitch 2011
         - Author of the  LightSwitch Central Blog

    FREE Download: Luminous Tools for LightSwitch
    (a Visual Studio productivity extension for LightSwitch)
     
    Click Mark as Answer, if someone's reply answers your question
    Click  Vote as Helpful, if someone's reply is helpful
     
    By doing this you'll help everyone find answers faster.

    • Marked as answer by edm2 Tuesday, April 30, 2013 9:52 PM
    Tuesday, April 30, 2013 12:39 PM
    Moderator
  • Yann,

    You nailed it! I created a table (seat of the pants, roughing out an idea) with an ID but failed to make it a primary key. When I made it a PK LightSwitch recognized the table. (LightSwitch is kind of picky about enforcing good design practices! I'm not complaining but I am surprised.)

    Thanks,

    edm2

    Tuesday, April 30, 2013 9:52 PM
  • "LightSwitch is kind of picky about enforcing good design practices"

    Yes, it is. :-)

    "You nailed it!..Thanks"

    You're absolutely welcome!


    Yann Duran
         - Co-Author of Pro Visual Studio LightSwitch 2011
         - Author of the  LightSwitch Central Blog

    FREE Download: Luminous Tools for LightSwitch
    (a Visual Studio productivity extension for LightSwitch)
     
    Click Mark as Answer, if someone's reply answers your question
    Click  Vote as Helpful, if someone's reply is helpful
     
    By doing this you'll help everyone find answers faster.

    Wednesday, May 1, 2013 1:42 PM
    Moderator
  • I have the same problem. I have seven tables, some have a PK, some haven't. None of the tables is shown. EDIT: Now I have a PK on every table, and still they are not shown.

    Do I really need a PK on every table to see one of them?

    Does every PK have to be single-column?


    • Edited by Alexander U Wednesday, November 13, 2013 2:42 PM
    Wednesday, November 13, 2013 2:37 PM
  • @Alexander_U

    In order for LightSwitch to see the tables they must have at least one field that is unique and non-nullable. If you make sure that the PK fields that you have meet this you should be able to see them.


    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)

    Wednesday, November 13, 2013 3:07 PM