Skip to content

Commit 340ec0e

Browse files
committed
#16: Better solution for delete the database.
1 parent 5101a9a commit 340ec0e

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

SQLite.CodeFirst/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,12 @@ public override void InitializeDatabase(TContext context)
8787
}
8888
}
8989

90-
private void DeleteDatabase(TContext context, string databseFilePath)
90+
private static void DeleteDatabase(TContext context, string databseFilePath)
9191
{
9292
context.Database.Connection.Close();
9393
GC.Collect();
94-
95-
// TODO: Comment
96-
for (int i = 0; i < 5; i++)
97-
{
98-
try
99-
{
100-
File.Delete(databseFilePath);
101-
// TODO: Throw exception if 5 tries..
102-
break;
103-
}
104-
catch (Exception)
105-
{
106-
System.Threading.Thread.Sleep(1);
107-
}
108-
}
94+
GC.WaitForPendingFinalizers();
95+
File.Delete(databseFilePath);
10996
}
11097

11198
private void SaveHistory(TContext context)

0 commit comments

Comments
 (0)