I am trying to achieve offline database sync using Azure Mobile Apps. When I use the remote version (using MobileServiceClient.GetTable instead of MobileService.GetSyncTable) everything works successfully. However, I can't make it work with local SQLite database.
DatabaseContext class is registered as a singleton in the Autofac container.
public class DatabaseContext
{
private readonly MobileServiceClient _client;
private readonly MobileServiceSQLiteStore _store;
public DatabaseContext()
{
if (File.Exists(Constants.LocalDatabase))
{
File.Delete(Constants.LocalDatabase);
}
_client = new MobileServiceClient(Constants.ApiEndpoint);
_store = new MobileServiceSQLiteStore(Constants.LocalDatabaseName);
}
public async Task Initialize()
{
_store.DefineTable<Activities>();
await _client.SyncContext.InitializeAsync(_store);
await _client.SyncContext.PushAsync();
var activitiesTable = _client.GetSyncTable<Activities>();
await activitiesTable.PullAsync(null, activitiesTable.CreateQuery());
// DATA IS EMPTY
var data = await activitiesTable.CreateQuery().ToListAsync();
}
}
My model class:
public class Activities
{
public Guid Id { get; set; }
public string Name{ get; set; }
public DateTimeOffset? UpdatedAt { get; set; }
public DateTimeOffset? CreatedAt { get; set; }
public byte[] Version { get; set; }
}
When I look at my streaming logs inside the azure dashboard, I can see this request:
GET /tables/Activities $skip=0&$top=50&__includeDeleted=true&$skip=0&$top=50&__includeDeleted=true&X-ARR-LOG-ID=19cd669b-df9a-41ee-b86e-9db766fc8e01 443 - 70.52.250.32 ZUMO/4.0+(lang=Managed;+os=Android;+os_version=6.0.1;+arch=Unix;+version=4.0.0.0) - 200 0 0 3228 1241 2160
Calling it with Postman returns data.
Any idea?