Ticket Hash: | 165af4c68cd9dc26e6145abd44904f520cf18ded | ||
Title: | System.Data.SQLite.EF6 has lock on file after DbContext.Dispose() | ||
Status: | Closed | Type: | Incident |
Severity: | Important | Priority: | Medium |
Subsystem: | LINQ | Resolution: | External_Bug |
Last Modified: |
2020-10-29 02:38:52 4.68 years ago |
Created: |
2020-03-17 20:36:42 5.29 years ago |
Version Found In: | 1.0.112 |
User Comments: | ||||
anonymous added on 2020-03-17 20:36:42:
Trying to delete the file after performing my unit test failed. It failed because the file is still open used. System.IO.IOException : The process cannot access the file 'D:\ALAIN\GitHub\RPLV\DataAccessLayerTests\bin\Debug\test.sqlite' because it is being used by another process. Following is the code I used to reproduce the problem. [Fact] public void Open_close_with_Context() { //--- Setup SQLiteConnection connection = RplvContextFactory.Instance.CreateConnection($"Data Source={_testFile}") as SQLiteConnection; RplvContext contextTest = new RplvContext(connection, true); contextTest.Database.Connection.Should().BeSameAs(connection); //--- Action var result = contextTest.LuminaireDb.ToList(); //--- Verification contextTest.Database.Connection.State.Should().Be(ConnectionState.Closed); //--- Action contextTest.Dispose(); contextTest = null; //--- Verification File.Exists(_testFile).Should().BeTrue(); // failed throw IOException File.Delete(_testFile); } mistachkin added on 2020-03-18 18:20:02: Is it possible for you to use a debug build and see if the underlying connection is being closed? |