Question

I have created a .NET backend Mobile Service on Windows Azure using the code sample provided on the website http://www.windowsazure.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-store-dotnet-get-started-data/ . After deploying the service and running the Win 8 app, It creates a tabled automatically named TodoItems based on the code. But I cannot figure out how to add new tables to the service. I have tried the followings: 1. Adding a new EntityClass, TableController: Then as soon as adding a DbSet to the contextclass, clients receive Internal Server Error 500 even while accessing to TodoItems which are not changed. 2. Then I tried to add the table manually but I got the same error. 3. I also tried creating my table with the same structure as TodoItem using its script (adding CreatedAt, UpdatedAt, IsDeleted, triggers) but the problem still persists.

I just deployed the service on my local machine and connected remotely to the Azure DB and surprisingly, everything works fine. I have access to both tables but if I use the windows azure service I get the "Internal Server Error".

Was it helpful?

Solution

I just managed to solve the problem by:

  1. Dropping the database and service
  2. Recreating both
  3. Adding one item to each table in the Seed function of the database initializer (DropCreateDatabaseIfModelChanges class) so that it generates the table automatically.

OTHER TIPS

If you use the JavaScript backend in your mobile services

To add a new table to a JavaScript backend from the Management Portal, click Create, supply the Table Name, and select the insert, update, delete, and query permissions. When "dynamic schema" is enabled, Mobile Services automatically generate new columns based on the JSON object in the insert or update request.

If you use the .NET backend

It's recommended to use data migrations (see the second link below). To add a table you need to add a new property to the Code First data model that returns a DbSet based on a new model data type that inherits from the EntityData type.

It could be useful to read: Add Mobile Services to an existing app

It's also possible to use the SQL Server Management Studio to perform any DDL/DML operations.

For more information, please see the links below:

http://msdn.microsoft.com/library/azure/jj193162.aspx http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-how-to-use-code-first-migrations/

-Go to Azure Management Portal.

-Pick Mobile Services

-Pick your own service

-Go to "Data" Tab.

-Click the "+" Icon on the toolbar at the bottom of the screen.

This will get you to the "Create Table" screen where you can specify a table name and access policies.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top