简体   繁体   中英

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. 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? When I download the mobile services project from Azure, I can publish the service and it will run with a new ToDoItems table. So I open up a SQL query in Visual Studio and add a column and add some random data to the new column 'Individual':

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. 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. 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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