Hello, so then move your code out of a scoped using block or force the gc at the end before deleting the file
anyway what an ugly language! java almost died (google saved it, they should not have), and they did it again! calling that c#, by bad. Best Regards. On Thu, Feb 27, 2014 at 12:50 PM, Joe Strommen <joe.strom...@gmail.com>wrote: > After looking into this further, I think this is the same problem described > in ticket aba4549801, which was marked resolved in Sep 2013 ( > https://system.data.sqlite.org/index.html/tktview?name=aba4549801) > > I will add a comment to the ticket to try to get it re-opened. > > Thanks > Joe > > > On Thu, Feb 27, 2014 at 2:49 PM, mm.w <0xcafef...@gmail.com> wrote: > > > Hello, > > > > is it the class you use? > > > > https://github.com/peterhuene/sqlite-net/blob/master/src/SQLite.cs > > > > then extend SQLiteConnection and overwrite > > > > public void Dispose () to trace what's happening > > > > > > Best Regards. > > > > > > On Thu, Feb 27, 2014 at 12:33 PM, mm.w <0xcafef...@gmail.com> wrote: > > > > > Hello, > > > > > > reading quickly the doc > > > > > > "Constructs a new context instance using the existing connection to > > > connect to a database. The connection will not be disposed when the > > context > > > is disposed ifcontextOwnsConnection is false." > > > > > > base(existingConnection, false) { } > > > > > > Best Regards. > > > > > > > > > On Thu, Feb 27, 2014 at 12:28 PM, Joe Strommen <joe.strom...@gmail.com > > >wrote: > > > > > >> The end of the using() block automatically closes the connection. If > I > > >> remove the line with "efContext.TestEntities.Count()" then it works > > fine. > > >> > > >> > > >> On Thu, Feb 27, 2014 at 2:09 PM, mm.w <0xcafef...@gmail.com> wrote: > > >> > > >> > Hello, > > >> > > > >> > I don't know anything about c# and the Entity Framework, but > > something > > >> > obvious where do you close your connection? > > >> > > > >> > Best Regards. > > >> > > > >> > > > >> > On Wed, Feb 26, 2014 at 11:46 AM, Joe Strommen < > > joe.strom...@gmail.com > > >> > >wrote: > > >> > > > >> > > Hi all, > > >> > > I'm using SQLite with Entity Framework 6 and having a problem. > I > > >> am > > >> > > unable to delete the sqlite file, even though I'm disposing all my > > >> > > disposable objects. Below is a minimal code sample that > > demonstrates > > >> the > > >> > > issue. I'd appreciate any advice/workarounds you can provide. > I'm > > >> happy > > >> > > to enter a ticket for this, but I wanted to verify that I'm not > > doing > > >> > > something wrong first. > > >> > > > > >> > > (I'm using the latest System.Data.SQLite NuGet package, which is > > >> version > > >> > > 1.0.91) > > >> > > > > >> > > Thanks > > >> > > Joe Strommen > > >> > > > > >> > > class Program > > >> > > { > > >> > > public class TestContext : DbContext > > >> > > { > > >> > > public TestContext(DbConnection existingConnection) : > > >> > > base(existingConnection, false) { } > > >> > > > > >> > > public DbSet<TestEntity> TestEntities { get; set; } > > >> > > } > > >> > > > > >> > > public class TestEntity > > >> > > { > > >> > > public long Id { get; set; } > > >> > > > > >> > > public string Value { get; set; } > > >> > > } > > >> > > > > >> > > static void Main(string[] args) > > >> > > { > > >> > > var path = "test.sqlite"; > > >> > > if (File.Exists(path)) { File.Delete(path); } > > >> > > using (var sqliteConnection = new > SQLiteConnection("Data > > >> > > Source=" + path)) > > >> > > { > > >> > > sqliteConnection.Open(); > > >> > > > > >> > > using (var sqliteCmd = > > >> sqliteConnection.CreateCommand()) > > >> > > { > > >> > > sqliteCmd.CommandText = > > >> > > "CREATE TABLE TestEntities (Id INTEGER > > PRIMARY > > >> > KEY > > >> > > AUTOINCREMENT, Value TEXT);" + > > >> > > "INSERT INTO TestEntities ('Value') VALUES > > >> > > ('Value1'), ('Value2'), ('Value3');"; > > >> > > sqliteCmd.ExecuteNonQuery(); > > >> > > } > > >> > > > > >> > > using (var efContext = new > > >> TestContext(sqliteConnection)) > > >> > > { > > >> > > var entityCount = > > efContext.TestEntities.Count(); > > >> > > } > > >> > > } > > >> > > File.Delete(path); // Fails; the file is still locked. > > >> > > } > > >> > > } > > >> > > _______________________________________________ > > >> > > sqlite-users mailing list > > >> > > sqlite-users@sqlite.org > > >> > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > >> > > > > >> > _______________________________________________ > > >> > sqlite-users mailing list > > >> > sqlite-users@sqlite.org > > >> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > >> > > > >> _______________________________________________ > > >> sqlite-users mailing list > > >> sqlite-users@sqlite.org > > >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > >> > > > > > > > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users