Skip to content

Commit 628d93f

Browse files
committed
#16: Fix for .NET 4.0.
1 parent 83065e2 commit 628d93f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

SQLite.CodeFirst/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Data.Common;
34
using System.Data.Entity;
5+
using System.Data.Entity.Infrastructure;
46
using System.IO;
57
using System.Linq;
68
using SQLite.CodeFirst.Utility;
@@ -139,12 +141,11 @@ private bool IsSameModel(TContext context)
139141

140142
private IHistory GetHistoryRecord(TContext context)
141143
{
142-
return context.Set(historyEntityType)
143-
.AsNoTracking()
144-
.ToListAsync()
145-
.Result
146-
.Cast<IHistory>()
147-
.SingleOrDefault();
144+
// Yes, it seams to be complicated but it has to be done this way
145+
// in order to be supported by .NET 4.0.
146+
DbQuery dbQuery = context.Set(historyEntityType).AsNoTracking();
147+
IEnumerable<IHistory> records = Enumerable.Cast<IHistory>(dbQuery);
148+
return records.SingleOrDefault();
148149
}
149150

150151
private string GetHashFromModel(DbConnection connection)

0 commit comments

Comments
 (0)