This guide helps you migrate from Akavache V10.x to V11.1 while preserving your existing data and functionality.
Akavache V11.1 introduces significant architectural improvements while maintaining backward compatibility with your data. The main changes are in how you initialize and configure Akavache, not in the core API you use daily.
- Initialization Method: The
BlobCache.ApplicationNameandRegistrations.Start()methods are replaced with the builder pattern - Package Structure: Akavache is now split into multiple packages
- Serializer Registration: Must explicitly register a serializer before use
- ✅ Core API:
GetObject,InsertObject,GetOrFetchObjectwork identically - ✅ Data Compatibility: V11.1 reads all V10.x data without conversion
- ✅ Cache Types: UserAccount, LocalMachine, Secure, InMemory work the same
- ✅ Extension Methods: All your existing extension method calls work
<PackageReference Include="Akavache" Version="10.*" /><!-- Choose storage backend -->
<PackageReference Include="Akavache.Sqlite3" Version="11.1.*" />
<!-- Choose serializer -->
<PackageReference Include="Akavache.SystemTextJson" Version="11.1.*" />
<!-- OR for maximum compatibility: -->
<PackageReference Include="Akavache.NewtonsoftJson" Version="11.1.*" />// V10.x initialization
BlobCache.ApplicationName = "MyApp";
// or
Akavache.Registrations.Start("MyApp");
// Usage
var data = await BlobCache.UserAccount.GetObject<MyData>("key");
await BlobCache.LocalMachine.InsertObject("key", myData);// V11.1 initialization (RECOMMENDED: Explicit provider pattern)
using Akavache.Core;
using Akavache.SystemTextJson;
using Akavache.Sqlite3;
using Splat.Builder;
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MyApp")
.WithSqliteProvider() // REQUIRED: Explicit provider initialization
.WithSqliteDefaults());
// Usage (same API)
var data = await CacheDatabase.UserAccount.GetObject<MyData>("key");
await CacheDatabase.LocalMachine.InsertObject("key", myData);Create this helper method to ease migration:
public static class AkavacheMigration
{
public static void InitializeV11(string appName)
{
// Initialize with SQLite (most common V10.x setup)
// RECOMMENDED: Use explicit provider initialization
CacheDatabase
.Initialize<SystemJsonSerializer>(builder =>
builder
.WithSqliteProvider() // Explicit provider initialization
.WithSqliteDefaults(),
appName);
}
}
// Then in your app:
AkavacheMigration.InitializeV11("MyApp");Before (V10.x):
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
BlobCache.ApplicationName = "MyWpfApp";
base.OnStartup(e);
}
}
public class DataService
{
public async Task<User> GetUser(int userId)
{
return await BlobCache.UserAccount.GetOrFetchObject($"user_{userId}",
() => apiClient.GetUser(userId),
TimeSpan.FromMinutes(30));
}
}After (V11.1):
using Akavache.Core;
using Akavache.SystemTextJson;
using Akavache.Sqlite3;
using Splat.Builder;
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MyWpfApp")
.WithSqliteProvider()
.WithSqliteDefaults());
base.OnStartup(e);
}
}
public class DataService
{
public async Task<User> GetUser(int userId)
{
// Same API!
return await CacheDatabase.UserAccount.GetOrFetchObject($"user_{userId}",
() => apiClient.GetUser(userId),
TimeSpan.FromMinutes(30));
}
}Before (V10.x):
BlobCache.ApplicationName = "MySecureApp";
BlobCache.SecureFileStorage = new EncryptedBlobStorage("password");After (V11.1):
AppBuilder.CreateSplatBuilder()
.WithAkavache<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MySecureApp")
.WithEncryptedSqliteProvider()
.WithSqliteDefaults("password"));Before (V10.x):
BlobCache.ApplicationName = "MyApp";
BlobCache.LocalMachine = new SqliteBlobCache(@"C:\MyApp\cache.db");After (V11.1):
AppBuilder.CreateSplatBuilder()
.WithAkavache<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MyApp")
.WithSqliteProvider()
.WithLocalMachine(new SqliteBlobCache(@"C:\MyApp\cache.db"))
.WithSqliteDefaults());Before (V10.x):
// V10.x didn't have good DI support
BlobCache.ApplicationName = "MyApp";
container.RegisterInstance(BlobCache.UserAccount);After (V11.1):
// V11.1 has first-class DI support
AppBuilder.CreateSplatBuilder()
.WithAkavache<SystemJsonSerializer>(
"MyApp",
builder => builder.WithSqliteProvider().WithSqliteDefaults(),
(splat, instance) => container.RegisterInstance(instance));Use Newtonsoft.Json serializer to maintain 100% compatibility:
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<NewtonsoftBsonSerializer>(builder =>
builder.WithApplicationName("MyApp")
.WithSqliteProvider()
.WithSqliteDefaults());Use System.Text.Json for better performance:
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(builder =>
builder.WithApplicationName("MyApp")
.WithSqliteProvider()
.WithSqliteDefaults());V11.1 can read data written by V10.x and different serializers:
// This works! V11.1 can read V10.x data regardless of serializer choice
var oldData = await CacheDatabase.UserAccount.GetObject<MyData>("key_from_v10");You can migrate serializers gradually:
// 1. Start with Newtonsoft for compatibility
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<NewtonsoftBsonSerializer>(/* ... */);
// 2. Later, change to System.Text.Json for performance
// Old data will still be readable!
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(/* ... */);Before (V10.x):
public partial class App : Application
{
public App()
{
InitializeComponent();
BlobCache.ApplicationName = "MyMauiApp";
MainPage = new AppShell();
}
}After (V11.1):
// In MauiProgram.cs
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>();
// Initialize Akavache
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(cacheBuilder =>
cacheBuilder.WithApplicationName("MyMauiApp")
.WithSqliteProvider()
.WithSqliteDefaults());
return builder.Build();
}
}Add platform-specific SQLite support:
<!-- For iOS/Android -->
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.11" />// Test that old data is still accessible
try
{
var oldData = await CacheDatabase.UserAccount.GetObject<MyOldDataType>("existing_key");
Console.WriteLine("✅ Migration successful - old data accessible");
}
catch (Exception ex)
{
Console.WriteLine($"❌ Migration issue: {ex.Message}");
}// Test that new data can be stored and retrieved
var testData = new MyDataType { Value = "test" };
await CacheDatabase.UserAccount.InsertObject("migration_test", testData);
var retrieved = await CacheDatabase.UserAccount.GetObject<MyDataType>("migration_test");
Console.WriteLine(retrieved.Value == "test" ? "✅ New storage working" : "❌ Storage issue");// Compare V10 vs V11 performance
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for (int i = 0; i < 1000; i++)
{
await CacheDatabase.UserAccount.InsertObject($"perf_test_{i}", new MyData { Value = i });
}
stopwatch.Stop();
Console.WriteLine($"1000 inserts: {stopwatch.ElapsedMilliseconds}ms");// Fix: Ensure you register a serializer
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase<SystemJsonSerializer>(/* ... */);// Fix: Call WithSqliteProvider() before WithSqliteDefaults()
.WithSqliteProvider()
.WithSqliteDefaults()// Check if application name changed
builder.WithApplicationName("SameAsV10App") // Must match V10 app name- Updated package references
- Replaced initialization code
- Added explicit provider initialization
- Tested existing data access
- Verified new data storage
- Updated DI container registration (if applicable)
- Added platform-specific packages (mobile)
- Updated application shutdown code
V11.1 generally performs better than V10.x, especially with System.Text.Json:
- System.Text.Json: Faster than V10 across all scenarios
- Newtonsoft.Json: Comparable to V10 for small/medium data, may be slower for very large datasets
For best migration experience:
- Start with Newtonsoft.Json for compatibility
- Migrate to System.Text.Json when ready for optimal performance
If you encounter issues during migration:
- Check the Troubleshooting Guide
- Review the Configuration Documentation
- Ask on ReactiveUI Slack
- File an issue on GitHub
Remember: V11.1 is designed to be a drop-in replacement for V10.x with better performance and more features. Your existing data and most of your code will work without changes!