none
Using offline data sync in Mobile Services

    Question

  • Hi All,

    I am working on offline data sync in Mobile Services . Followed the below URL

    http://azure.microsoft.com/en-gb/documentation/articles/mobile-services-windows-store-dotnet-get-started-offline-data/#enable-offline-app

    Have an issue at store.DefineTable<TodoItem>();

    when i run the method i am getting any exception as 

    System.ArgumentException was unhandled by user code
      HResult=-2147024809
      Message=An item with the same key has already been added.
      Source=mscorlib
      StackTrace:
           at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
           at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
           at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
           at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
           at Microsoft.WindowsAzure.MobileServices.SQLiteStore.MobileServiceSQLiteStore.DefineTable(String tableName, JObject item)
           at Microsoft.WindowsAzure.MobileServices.SQLiteStore.MobileServiceSQLiteStoreExtensions.DefineTable[T](MobileServiceSQLiteStore store, MobileServiceJsonSerializerSettings settings)
           at Microsoft.WindowsAzure.MobileServices.SQLiteStore.MobileServiceSQLiteStoreExtensions.DefineTable[T](MobileServiceSQLiteStore store)

      private async Task InitLocalStoreAsync()
    {
        if (!App.MobileService.SyncContext.IsInitialized)
        {
            var store = new MobileServiceSQLiteStore("localstore.db");
            store.DefineTable<TodoItem>();
            await App.MobileService.SyncContext.InitializeAsync(store);
        }

        await SyncAsync();
    }

    Need help.

    Thanks,

    Sai.

    Tuesday, April 7, 2015 12:32 PM

Answers