locked
Problem Expanding Underlying Database (getting "There are no accessible tables" error) RRS feed

  • Question

  • User1848880975 posted

    I have an existing Dynamic Data application that's working fine. I'm working on some enhancements to the application which require me to make some changes to the underlying data model -- in particular, adding one new table which will contain some detail records related to an existing table.

    Earlier today I created a copy of the existing database, then updated the underlying schema. I then changed the connection string in my Dynamic Data application to point to the DEV database, and updated the LinqToSQL to reference the new table. When I tried to run the application, I started getting the dreaded "there are no accessible tables" error from the Default.aspx page. (Yes, I did go into my global.asax file and very that Scaffolding is still enabled for all tables!)

    Thinking it might have been a problem with my LinqToSQL classes, I deleted them completely, then recreated them, but still no luck.

    What's baffling/frustrating is that if I go back and change my connection string to point to the old unaltered database, the app still runs fine. It makes me think I'm missing a reference somewhere, but for the life of me I can't find it.

    Any help is appreciated!

    Saturday, March 3, 2012 3:05 PM

Answers

  • User1848880975 posted

    I checked and the table did have a Primary Key set. I actually did some more stepping through the code and found the issue, and it's rather embarassing! I am using your SecureMetaModel classes, and when I added a reference to the new table in the Metadata.cs class I specified the table name (Payments) forgetting that I needed do de-pluralize the table name when referring to its entity (Payment). Embarassed

    The last time I spent that much time wrestling with a single letter of the alphabet, I was a wee one watching Sesame Street!

    Incidentally, I was curious about something: how does the code know to look for a file called "Metadata.cs"? Is this a special class that is always expected to be in a particular location?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 4, 2012 12:28 PM

All replies

  • User-330204900 posted

    If all you change is the connection string, that is really strange, I've had invalid connection string and still seent eh list of tables so I'm not sure what is going on.

    Saturday, March 3, 2012 7:21 PM
  • User1848880975 posted

    So... I pointed the application back to the original database and just added the new table to it -- so now the database has 3 tables instead of 2. When I review the propertyies of MetaModel.Default, all 3 of the Tables are present in the Tables property, but just the original 2 are present in the VisibleTables property.

    I'm using the SecureMetaModel code you provided on your blog by the way (thank you!) and I did update the Metadata.cs file to include references to the new table...

    Saturday, March 3, 2012 8:13 PM
  • User-330204900 posted

    There must be no primary key defined in the new table.

    Sunday, March 4, 2012 6:33 AM
  • User1848880975 posted

    I checked and the table did have a Primary Key set. I actually did some more stepping through the code and found the issue, and it's rather embarassing! I am using your SecureMetaModel classes, and when I added a reference to the new table in the Metadata.cs class I specified the table name (Payments) forgetting that I needed do de-pluralize the table name when referring to its entity (Payment). Embarassed

    The last time I spent that much time wrestling with a single letter of the alphabet, I was a wee one watching Sesame Street!

    Incidentally, I was curious about something: how does the code know to look for a file called "Metadata.cs"? Is this a special class that is always expected to be in a particular location?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 4, 2012 12:28 PM
  • User-330204900 posted

    Well that's what SecureMetaModel does is make it secure Laughing we've all been there.

    Sunday, March 4, 2012 6:09 PM