From a5a4217bccd7fe748e3fc199ee1f63ee1aa96522 Mon Sep 17 00:00:00 2001 From: superkid200 Date: Mon, 22 Jul 2019 08:00:56 +0700 Subject: [PATCH] SQLite initialization error The dbOptions variable should be a DBContextOptions, not a DBContextOptionsBuilder The SqlContosoRepository class requires a ContosoContext, not a DbContextOptions. --- ContosoApp/App.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ContosoApp/App.xaml.cs b/ContosoApp/App.xaml.cs index 20d3643..3dd8bf0 100644 --- a/ContosoApp/App.xaml.cs +++ b/ContosoApp/App.xaml.cs @@ -108,8 +108,8 @@ public static void UseSqlite() File.Copy(demoDatabasePath, databasePath); } var dbOptions = new DbContextOptionsBuilder().UseSqlite( - "Data Source=" + databasePath); - Repository = new SqlContosoRepository(dbOptions); + "Data Source=" + databasePath).Options; + Repository = new SqlContosoRepository(new ContosoContext(dbOptions)); } /// @@ -119,4 +119,4 @@ public static void UseSqlite() public static void UseRest() => Repository = new RestContosoRepository("https://customers-orders-api-prod.azurewebsites.net/api/"); } -} \ No newline at end of file +}