'Error : Value cannot be null. Parameter name : path 1, when add a new Azure Mobile Apps table Controller

It's the first time I create a back end for my Xamarin.Forms application. I follow instructions on Azure Portal -> Quick-Start, create a data connection, choose c# in step 2 and download the project.

Build it and now I want to add a new table. So :

  • I add the class in DataObjects folder.
  • I add the line in the Context file : public DbSet<Coffee> Coffees{ get; set; }
  • And when I try to add the Azure Mobile Apps table controller, an error message tell me :

        Value cannot be null. Parameter name : path1.
    

What can I do to fix that ?

Sorry for my bad English.

Have a nice day!



Solution 1:[1]

I have the same problem, and the problem is also mentioned on the Visual Studio Development community: https://developercommunity.visualstudio.com/content/problem/563354/adding-a-new-azure-mobile-apps-table-controller-or.html

Meanwhile you can work around the problem by creating the controller in code. I've tested the following steps for a Azure Mobile Apps Table Controller for a Xamarin Forms app:

  1. Add a new class to the Controllers folder, i.e. {YourDataObject}Controller.cs
  2. Take an existing and working controller and copy the code into the new controller file.
  3. Replace {OldMobileAppName}Service and {OldMobileAppName}Context with {NewMobileAppName}Service and {NewMobileAppName}Context
  4. Replace {OldDataObjectName} with {NewDataObjectName}

Finally publish your solution.

Solution 2:[2]

Configuring a Table Controller requires three steps:

  1. Create a Data Transfer Object (DTO) class.
  2. Configure a table reference in the Mobile DbContext class.
  3. Create a table controller.

A Data Transfer Object (DTO) is a plain C# object that inherits from EntityData. An example from the documentation:

public class TodoItem : EntityData
{
    public string Text { get; set; }
    public bool Complete {get; set;}
}

Please reference this documentation for more information.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Logiza DevOps
Solution 2 Agostino