The only workaround I have found is to either restart VS altogether or use TaskManager to kill the QTAgent32.exe process, which will restart itself automatically (without the open file handle). Not a very elegant solution, methinks.
Code: Select all
public DBDataContext CreateContext(string path, bool failIfMissing)
{
SQLiteConnectionStringBuilder sb = new SQLiteConnectionStringBuilder();
sb["Data Source"] = path;
sb["FailIfMissing"] = failIfMissing;
string connectionString = sb.ToString();
DBDataContext db = new DBDataContext(connectionString);
if (!db.DatabaseExists())
{
db.CreateDatabase();
}
return (db);
}
[TestMethod]
public void CreateDb()
{
DBDataContext db = null;
string path = @"E:\DBTest\DBTest.db";
File.Delete(path);
try
{
db = CreateContext(path, /*failIfMissing*/false);
Assert.IsTrue(db.Draws.Count() == 0);
Draw newDraw = new Draw();
.....
db.Draws.InsertOnSubmit(newDraw);
db.SubmitChanges();
Assert.IsTrue(db.Draws.Count() == 1);
}
finally
{
if (db != null)
{
db.Dispose();
}
}
}