none
[Node.js][Mobile Apps] Accessing existing tables in App Service Mobile Apps RRS feed

  • Question

  • Hi,

    I'm creating a mobile app to access the SQL Azure database of an existing web app. I am using the new Azure App Service Mobile Apps. I am using Node.js backend and using Easy Tables (on the Azure Portal interface) to create tables. 

    Question: Is it possible for me to use EXISTING tables (that are currently used by my web app) instead of creating new tables? Will I be able to access the existing table the same way as I reference the new tables created using Easy Tables? (I don't see existing tables listed under Easy Tables.) Or do I need to create new tables in order to reference them?

    Thanks in advance for the help.



    Tuesday, January 19, 2016 5:16 AM

Answers

  • Hi,

    You can set up the table using the standard TableController and EntityFramework.  Note that Azure Mobile adds five fields - id, createdAt, updatedAt, version and deleted.  The id is usually the problem as Azure Mobile requires this to be a string rather than the normal int.  Since this is a change to the data model, you will need to do a database migration as part of bringing the table in.

    -Adrian

    • Marked as answer by Windhoek Wednesday, January 20, 2016 1:00 PM
    Tuesday, January 19, 2016 7:25 PM

All replies

  • See this question the answer to which shows you how to access tables via azureMobile.tables('TABLE_NAME').

    Mathew Charles [MSFT]

    Tuesday, January 19, 2016 5:19 AM
  • Thanks Mathew. Can I ask: How would you do the same thing for a .Net backend instead of Node.js?
    Tuesday, January 19, 2016 4:10 PM
  • Hi,

    You can set up the table using the standard TableController and EntityFramework.  Note that Azure Mobile adds five fields - id, createdAt, updatedAt, version and deleted.  The id is usually the problem as Azure Mobile requires this to be a string rather than the normal int.  Since this is a change to the data model, you will need to do a database migration as part of bringing the table in.

    -Adrian

    • Marked as answer by Windhoek Wednesday, January 20, 2016 1:00 PM
    Tuesday, January 19, 2016 7:25 PM
  • Thanks Adrian. This clarifies things a lot. So it seems I can't simply access the existing tables, because it needs the 5 system properties fields. 

    Could you clarify what you mean by "you will need to do a database migration as part of bringing the table in"?

    Thanks very much.

    Wednesday, January 20, 2016 12:55 PM