Overview
Artifact ID: | 3021e258a7fa610934535efcfc4e7e3eec001b12 |
---|---|
Ticket: | 165af4c68cd9dc26e6145abd44904f520cf18ded
System.Data.SQLite.EF6 has lock on file after DbContext.Dispose() |
User & Date: | anonymous 2020-03-17 20:36:42 |
Changes
- foundin changed to: "1.0.112"
- icomment:
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); }
- login: "anonymous"
- mimetype: "text/plain"
- private_contact changed to: "22e3ca59f6ea2f967118a9b57df213a0a0bce9a2"
- severity changed to: "Critical"
- status changed to: "Open"
- title changed to:
System.Data.SQLite.EF6 has lock on file after DbContext.Dispose()
- type changed to: "Code_Defect"