Reputation: 13
How can I add additional tables in azure mobile services and programmatically insert and read data. I tried doing it similarly as the code from TodoItems table. My new table is created and I can insert data manually by using sql, but when I use
private MobileServiceCollection<User,User> users;
private IMobileServiceTable<User> userTable = App.MobileService.GetTable<User>();
and
users = await userTable.ToCollectionAsync();
I get
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
Do you have any ideas how I can do it?
Upvotes: 0
Views: 605
Reputation: 91
As Matt points out, to add a table to a .NET backend, you just add a new property to the Code First data model that returns a DbSet based on a new model data type (which inherits from the EntityData type).
Make sure that you also read the topic How to make data model changes to a .NET backend mobile service to learn about what happens when you try to change the data model of a .NET backend mobile service.
Upvotes: 0
Reputation: 825
If you are using the .NET backend you'll need to do the following:
This should provide the API you need and automatically add the DBset property to the ef context for you. Don't forget to publish your application to Azure if you are testing against the deployed version and not the local version.
If you can provide more details on the exception you get when you hit that breakpoint, it would help. Check the locals window in Visual Studio or examine the arguments to the current method.
Upvotes: 2