0
votes

I am trying to make a mobile app, which will use the Azure database system. I am having alot of trouble making my own table, and have been running in coding circles for a couple of weeks. I just can't figure out what and how to change.

I can get the todolist up and running from azure, and i have tried to make my own table in the backend with a dataobject and a controller, but after adding the DbSet om the context, the todolist part breaks when i try to run the app.

How do i add my own stuff to the app, so that i can have a table of persons for example, instead of the todolist?

Thank you so much in advance. this is very confusing to me.

This is what i've done:

In the backend, i made a person class inhereting the EntityData class and have a firstname string property and a lastname string property Then i added

public DbSet<Person> Persons { get; set; }

and then a Personcontroller through the Add -> Controller -> Azure Mobile Apps Table Controller in visual studio 2017

Then in the app i downloaded from azure, i made the person class public class Person {

    [JsonProperty(PropertyName = "firstName")]
    public string firstName { get; set; }

    [JsonProperty(PropertyName = "lastName")]
    public string lastName { get; set; }

    [JsonProperty(PropertyName = "id")]
    public string id { get; set; }

 }

Then made the table

 IMobileServiceTable<Person> PersonTable = client.GetTable<Person>();

Then tried to insert into the table

        Person peter = new Person();
        peter.firstName = "Peter";
        peter.lastName = "Friis";
        await personTable.InsertAsync(peter);

but that gives the error:

Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: 
'The request could not be completed.  (Internal Server Error)'
1
please add the code you have tried to your postKen Tucker
Tried to do it. There is a lot of code, as i use the projects from Azure mobile app quickstart.Kasper Hangaard
Have you solved this issue, do you need further assistance?Bruce Chen

1 Answers

0
votes

According to your description, I assumed that you are using C# backend with SQL database. I would recommend that you could add the following code under the ConfigureMobileApp method of Startup.MobileApp.cs file for collecting the detailed error message.

config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

Before inserting the new record to your table via the mobile client SDK, you could leverage the postman or fiddler to simulate the insert operation as follows to narrow this issue:

enter image description here

For more details about http table interface, you could refer to here.

Additionally, since you are adding your custom tables, please make sure you have manually updated your database to support your new database model or configure the Automatic Code First Migrations. For more details, you could refer to adrian hall's book about Implementing Table Controllers.