Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.android Azure移动服务表与c#类不匹配:错误:只能通过';id';财产_Xamarin.android_Xamarin_Azure Mobile Services - Fatal编程技术网

Xamarin.android Azure移动服务表与c#类不匹配:错误:只能通过';id';财产

Xamarin.android Azure移动服务表与c#类不匹配:错误:只能通过';id';财产,xamarin.android,xamarin,azure-mobile-services,Xamarin.android,Xamarin,Azure Mobile Services,我刚刚重构了使用Azure移动服务作为后端的Xamarin Android应用程序。最近我犯了一个非常奇怪的错误 尝试将新项目插入数据库时: _client.GetTable<T>().InsertAsync(instance) 尝试将Id属性的数据类型从字符串更改为int。Azure将字符串而不是int用作PKs。如果你的应用程序中有旧数据,它可能会工作到某一点,因为SQLite在类型方面非常宽容。但在某些情况下,例如,如果使用外键关系,则必须迁移数据库。Jan,您使用的是.NE

我刚刚重构了使用Azure移动服务作为后端的Xamarin Android应用程序。最近我犯了一个非常奇怪的错误

尝试将新项目插入数据库时:

_client.GetTable<T>().InsertAsync(instance)

尝试将Id属性的数据类型从字符串更改为int。

Azure将字符串而不是int用作PKs。如果你的应用程序中有旧数据,它可能会工作到某一点,因为SQLite在类型方面非常宽容。但在某些情况下,例如,如果使用外键关系,则必须迁移数据库。

Jan,您使用的是.NET还是JavaScript后端?Yavor,我使用的是JavaScript后端。
using Microsoft.WindowsAzure.MobileServices;
using System;

namespace Core.Models
{
    public class PostAction
    {

        public string Id { get; set; }
        public string UserId { get; set; } 
        public string ImageURL { get; set; }

        [CreatedAt]
        public DateTime CreatedAt { get; set; }

        [UpdatedAt]
        public DateTime UpdatedAt { get; set; }

        [Version]
        public string Version { get; set; }
     }
}