diff --git a/src/System.Data.Jet/JetStoreSchemaDefinition/JetStoreDatabaseHandling.cs b/src/System.Data.Jet/JetStoreSchemaDefinition/JetStoreDatabaseHandling.cs index 50913dd..ed79f03 100644 --- a/src/System.Data.Jet/JetStoreSchemaDefinition/JetStoreDatabaseHandling.cs +++ b/src/System.Data.Jet/JetStoreSchemaDefinition/JetStoreDatabaseHandling.cs @@ -34,7 +34,7 @@ namespace System.Data.Jet.JetStoreSchemaDefinition RegexOptions.IgnoreCase); _regExExtractFilenameFromConnectionString = new Regex( - @"provider=.*;\s*data\s+source\s*=\s*(?.*)\s*;??.*$", + @"provider=.*;\s*data\s+source\s*=\s*(?[^;]*)\s*;?.*$", RegexOptions.IgnoreCase); diff --git a/test/EFCore.Jet.Integration.Test/DatabaseHandlingTest.cs b/test/EFCore.Jet.Integration.Test/DatabaseHandlingTest.cs new file mode 100644 index 0000000..fc50af3 --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/DatabaseHandlingTest.cs @@ -0,0 +1,45 @@ +using System; +using System.IO; +using EntityFrameworkCore.Jet; +using Microsoft.EntityFrameworkCore; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EFCore.Jet.Integration.Test +{ + [TestClass] + public class DatabaseHandlingTest + { + [TestMethod] + public void EnsureDeleted_Github21() + { + File.Delete(DatabaseHandlingTestContext.GetDbPath()); + + using (var ctx = new DatabaseHandlingTestContext()) + { + ctx.Database.EnsureCreated(); + } + + Assert.IsTrue(File.Exists(DatabaseHandlingTestContext.GetDbPath()), "The db has not been created"); + + using (var ctx = new DatabaseHandlingTestContext()) + { + ctx.Database.EnsureDeleted(); + } + + Assert.IsFalse(File.Exists(DatabaseHandlingTestContext.GetDbPath()), "The db has not been deleted"); + + } + public class DatabaseHandlingTestContext : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseJet($"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={GetDbPath()};"); + } + + public static string GetDbPath() + { + return Path.Combine(Helpers.GetTestDirectory(), "db.mdb"); + } + } + } +} diff --git a/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj b/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj index 5c3bf5c..f049c07 100644 --- a/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj +++ b/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj @@ -202,6 +202,7 @@ +