在Azure中为Xamarin Offline Sync设置MySQL后端 [英] Set up MySQL back-end in Azure for Xamarin Offline Sync

查看:92
本文介绍了在Azure中为Xamarin Offline Sync设置MySQL后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过Azure Portal建立的MySQL数据库,当前托管在ClearDB上.我使用Xamarin Forms创建了一个移动应用程序,该应用程序实现了一个SQLite数据库,该数据库在其中存储了与我的应用程序相关的信息.我正在使用Microsoft.WindowsAzure.MobileServices.SQLiteStore库实现离线同步功能,并且正在使用以下功能:

I have a MySQL database set up through the Azure Portal, currently hosted on ClearDB. I have created a mobile app using Xamarin Forms that implements an SQLite database which stores relevant information for my app in it. I am implementing offline sync functionality using the Microsoft.WindowsAzure.MobileServices.SQLiteStore library, and I am using functions such as:

  • await table.ToListAsync();

await table.UpdateAsync(entry);

await client.SyncContext.PushAsync();

我最后要做的是将本地SQLite数据库与我创建的AzureMySQL数据库进行同步.如何使用C#(或Node.js ..或ANY语言)实现此目的,以便我的SQLite数据库可以将条目与Azure MySQL数据库同步.

The last thing I need to do is sync my local SQLite database with the Azure cloud MySQL database I have created. How do I implement this in C# (or Node.js .. or ANY language) such that my SQLite database can sync entries with my Azure MySQL database.

谢谢!

推荐答案

根据您的要求,我尝试通过Visual Studio创建我的 Azure移动应用项目,并安装

According to your requirement, I tried to create my Azure Mobile App project via Visual Studio, and install MySql.Data.Entity 6.9.9 which supports MySQL for EF6, then create my table controller working with my DBContext for MySQL.

我创建了一个数据库模型,该模型继承了

I created my db model that inherits the EntityData which contains the table column type DateTimeOffset, but I encountered a incompatible error message. Then I found there is a known bug in MySQL Connector as follows:

使用类型为 DateTimeOffset 的列创建的Entity Framework DbContext对象返回错误,指示DateTimeOffset值与 DateTime Timestamp 值不兼容. (缺陷号24732001)

An Entity Framework DbContext object created with a column of type DateTimeOffset returned an error indicating that DateTimeOffset values were incompatible with DateTime and Timestamp values. (Bug #24732001)

我找到了发行说明关于MySQL Connector/NET,然后我尝试升级到 MySql.Data.Entity 7.0.7-m61 ,但是关于 TypeLoadException-遇到MySqlEFConfiguration .

I found a release note about MySQL Connector/NET, then I tried to upgrade to MySql.Data.Entity 7.0.7-m61, but another problem about TypeLoadException - MySqlEFConfiguration encountered.

由于您的目标是对具有azure移动应用程序的Xamarin应用程序使用脱机同步,所以我建议您可以尝试将sql数据库或azure表存储用于数据存储而不是MySQL,这可以在其中构建移动应用程序后端一种简单的方法.您可以参考

Since your goal is to use offline sync for your Xamarin app with azure mobile app, I recommend that you could try to use sql database or azure table storage for your data storage instead of MySQL, which could build your mobile app backend in a simple way. You could refer to here for getting started with it.

这篇关于在Azure中为Xamarin Offline Sync设置MySQL后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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