种子表.NET后端Azure的移动应用程序错误 [英] Seed table .NET backend Azure Mobile Apps error

查看:166
本文介绍了种子表.NET后端Azure的移动应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要一个数据对象我自己添加到Azure的移动应用之上的是提供内的TodoItem 在模板中。这里是我做了什么:

I want to add a DataObject of my own to Azure Mobile Apps on top of the TodoItem that is supplied in the template. Here is what I have done:


  1. 添加新的数据对象

public class Digests : EntityData
{
    public string Title { get; set; }
    public string ImageURI { get; set; }
}


  • 创建一个名为新控制器 DigestsController.cs

    添加公共DbSet<&精华GT; DigestItems {搞定;组; } 我的 AppContext.cs 。据说这是为了创建将持有精华项目表。

    Add public DbSet<Digests> DigestItems { get; set; } to my AppContext.cs. This is supposed to create the table that will hold Digests items.

    添加 context.Set&LT;精华方式&gt;()加入(新精华{ID =2016年,标题=测试,ImageURI =someUriHere}); 我的 Startup.MobileApp.cs 种子 AppInitializer 类。这应该是种子数据的一排在我的精华表。

    Add context.Set<Digests>().Add(new Digests { Id = "2016", Title = "Test", ImageURI = "someUriHere" }); to my Startup.MobileApp.cs on the Seed under the AppInitializer class. This is supposed to seed a row of data in my Digests table.

    据<一个href=\"http://stackoverflow.com/questions/25016543/extending-base-mobile-azure-sample-net-backend\">this问题以及他解决的方式,这应该工作!但每当我试图从我的客户端应用程序下拉数据:

    According to this question and the way he solved it, this should work! But whenever I try to pull down data from my client app:

    public static MobileServiceClient MobileService = new MobileServiceClient("http://app.azurewebsites.net/");
    IMobileServiceTable<Digests> Digests = App.MobileService.GetTable<Digests>();
    Weeks = await Digests.ToListAsync();
    

    或下拉与模板的应用程序的数据,我可以从Azure的门户网站下载:

    Or pull down data with the template app that I can download from Azure Portal:

    private MobileServiceCollection<TodoItem, TodoItem> items;
    private IMobileServiceTable<TodoItem> todoTable = App.MobileService.GetTable<TodoItem>();
    items = await todoTable.Where(todoItem => todoItem.Complete == false).ToCollectionAsync();
    

    我得到这样的:

    在这里输入的形象描述
    此外,当我进入SQL Server Management Studio中没有什么!否 TodoItems 表(这应该从模板code在那里),没有精华表。

    Also, when I go into SQL Server Management Studio there's nothing! No TodoItems table (which should be there from the template code) and no Digests table.

    我是什么在这里失踪?

    推荐答案

    下面是我工作:


    1. 创建DataModels

    2. 创建控制器(Visual Studio中自动提示的移动应用程序创建表)。

    3. 如果你想(完全可选)进入Startup.MobileApps.cs和种子。

    这篇关于种子表.NET后端Azure的移动应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆