简体   繁体   English

将列添加到Azure SQL数据库并使用Azure移动服务显示

[英]Add column to Azure SQL Database and display using Azure Mobile Services

I'm a newbie to dealing with Azure SQL Databases and Mobile Services. 我是处理Azure SQL数据库和移动服务的新手。 Does anyone know if it is possible to add a column to Azure SQL Database without having to go through the publish process in Visual Studio? 有谁知道不必在Visual Studio中完成发布过程即可向Azure SQL数据库添加列吗? When I download the mobile services project from Azure, I can publish the service and it will run with a new ToDoItems table. 当我从Azure下载移动服务项目时,我可以发布该服务,它将与新的ToDoItems表一起运行。 So I open up a SQL query in Visual Studio and add a column and add some random data to the new column 'Individual': 因此,我在Visual Studio中打开一个SQL查询,并添加一列,并将一些随机数据添加到新列“个人”中:

ALTER TABLE Numboo.TodoItems
ADD Individual nvarchar(max)

INSERT INTO Numboo.TodoItems (Text,Complete,Deleted,Individual)
VALUES ('90987834',1,0,'test data xxxxx')

But when I request the data from the table using mobile services, the data in the new column is null when I query the table 但是,当我使用移动服务从表中请求数据时,查询表时新列中的数据为空

private MobileServiceCollection<TodoItem, TodoItem> demo;
private IMobileServiceTable<TodoItem> demoTable = App.MobileService.GetTable<TodoItem>();
demo = await demoTable.ToCollectionAsync();
//Individual is null

instead of "test data xxxxx" which I inserted via a sql query. 而不是我通过sql查询插入的“测试数据xxxxx”。 Does anyone know if this is even possible to do it this way (add a column via script and access it using mobile services)? 有谁知道这样做是否有可能(通过脚本添加一列并使用移动服务访问它)? Or point me in the right direction or to an answer on SO if there is one? 或指出正确的方向,或者在有答案的情况下为我提供答案? I'm not sure what I would be searching for. 我不确定要搜索什么。 Thanks. 谢谢。

NB: I have updated the model/entity to reflect the new column in the database but that didn't make any difference: 注意:我已经更新了模型/实体以反映数据库中的新列,但这没有任何区别:

You do need to deploy your service with an updated model that matches the table schema/the model you want your API to expose. 您确实需要使用与表架构/您希望API公开的模型匹配的更新模型来部署服务。 It's not enough to just change the client model. 仅更改客户端模型是不够的。

Now, your question is specifically about publishing from VS, and although a deployment is required, you have other deployment options, including continuous deployment, which you can learn more about here: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-store-code-source-control/ 现在,您的问题专门针对从VS发布,尽管需要进行部署,但是您还有其他部署选项,包括连续部署,您可以在此处了解更多信息: https : //azure.microsoft.com/en-us/文档/文章/移动服务-dotnet-后端存储代码源控制/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM