diff --git a/build/GlobalAssemblyInfo.cs b/build/GlobalAssemblyInfo.cs
index fd77301..9eccaee 100644
--- a/build/GlobalAssemblyInfo.cs
+++ b/build/GlobalAssemblyInfo.cs
@@ -19,4 +19,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyVersion("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
-[assembly: AssemblyInformationalVersion("2.2.0-preview2")]
\ No newline at end of file
+[assembly: AssemblyInformationalVersion("2.2.0-preview5")]
\ No newline at end of file
diff --git a/msbuild/EFCore.Jet.nuspec b/msbuild/EFCore.Jet.nuspec
index 28f3a47..5445dee 100644
--- a/msbuild/EFCore.Jet.nuspec
+++ b/msbuild/EFCore.Jet.nuspec
@@ -9,10 +9,10 @@
false
Allows Jet (Microsoft Access mdb or accdb format files) to be used with Entity Framework Core
Allows Jet (Microsoft Access mdb or accdb format files) to be used with Entity Framework Core
- for EF Core 2.1
+ for EF Core 2.2
-
+
diff --git a/src/System.Data.Jet/JetCommand.cs b/src/System.Data.Jet/JetCommand.cs
index e2d7da4..868bc4a 100644
--- a/src/System.Data.Jet/JetCommand.cs
+++ b/src/System.Data.Jet/JetCommand.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Data.Common;
using System.Data.Jet.JetStoreSchemaDefinition;
using System.Data.OleDb;
-using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
@@ -20,7 +19,7 @@ namespace System.Data.Jet
private int? _rowCount = null;
private static readonly Regex _skipRegularExpression = new Regex(@"\bskip\s(?@.*)\b", RegexOptions.IgnoreCase);
- private static readonly Regex _selectRowCountRegularExpression = new Regex(@"^\s*select\s*@@rowcount\s*$", RegexOptions.IgnoreCase);
+ private static readonly Regex _selectRowCountRegularExpression = new Regex(@"^\s*select\s*@@rowcount\s*[;]?\s*$", RegexOptions.IgnoreCase);
private static readonly Regex _ifStatementRegex = new Regex(@"^\s*if\s*(?not)?\s*exists\s*\((?.+)\)\s*then\s*(?.*)$", RegexOptions.IgnoreCase);
///
@@ -277,7 +276,6 @@ namespace System.Data.Jet
return null;
}
-
///
/// Executes the non query.
///
@@ -310,6 +308,13 @@ namespace System.Data.Jet
for (int i = 0; i < commandTextList.Length; i++)
{
string commandText = commandTextList[i];
+ if (_selectRowCountRegularExpression.Match(commandText).Success)
+ {
+ if (_rowCount == null)
+ throw new InvalidOperationException("Invalid " + commandText + ". Run a DataReader before.");
+ returnValue = _rowCount.Value;
+ continue;
+ }
commandText = ParseIdentity(commandText);
commandText = ParseGuid(commandText);
@@ -386,8 +391,10 @@ namespace System.Data.Jet
private int InternalExecuteNonQuery(string commandText)
{
+ // ReSharper disable NotAccessedVariable
int topCount;
int skipCount;
+ // ReSharper restore NotAccessedVariable
string newCommandText;
if (!CheckExists(commandText, out newCommandText))
return 0;
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 18a9c45..72d39fe 100644
--- a/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj
+++ b/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj
@@ -241,6 +241,8 @@
+
+
@@ -248,6 +250,7 @@
+
diff --git a/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Context.cs b/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Context.cs
new file mode 100644
index 0000000..60721a1
--- /dev/null
+++ b/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Context.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Data.Common;
+using EntityFrameworkCore.Jet;
+using Microsoft.EntityFrameworkCore;
+
+namespace EFCore.Jet.Integration.Test.Model78_MigrationUpdate
+{
+ public class Context : DbContext
+ {
+
+ public Context(DbConnection connection) :
+ base(new DbContextOptionsBuilder().UseJet(connection, _ => _.MigrationsAssembly(typeof(Context).Assembly.GetName().Name)).Options)
+ {
+ TestBase.TryCreateTables(this);
+ }
+
+ public DbSet Students { get; set; }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+ modelBuilder.Entity().HasIndex(_ => _.StudentName);
+ }
+ }
+}
diff --git a/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Student.cs b/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Student.cs
new file mode 100644
index 0000000..1677494
--- /dev/null
+++ b/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Student.cs
@@ -0,0 +1,26 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace EFCore.Jet.Integration.Test.Model78_MigrationUpdate
+{
+ [Table("Students_78")]
+ public class Student
+ {
+ public int StudentId { get; set; }
+
+ [Required]
+ [MaxLength(50)]
+ // Index are supported only with fluent API
+ /*[Index]*/
+ public string StudentName { get; set; }
+
+ public string Notes { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("{2}: {0} - {1}", StudentId, StudentName, base.ToString());
+ }
+ }
+
+}
diff --git a/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Test.cs b/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Test.cs
new file mode 100644
index 0000000..54c15b3
--- /dev/null
+++ b/test/EFCore.Jet.Integration.Test/Model78_MigrationUpdate/Test.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Data.Common;
+using System.Data.Jet;
+using System.Data.OleDb;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace EFCore.Jet.Integration.Test.Model78_MigrationUpdate
+{
+ [TestClass]
+ public class Test
+ {
+
+ protected DbConnection GetConnection()
+ {
+ // ReSharper disable once CollectionNeverUpdated.Local
+
+ OleDbConnectionStringBuilder oleDbConnectionStringBuilder = new OleDbConnectionStringBuilder();
+ //oleDbConnectionStringBuilder.Provider = "Microsoft.Jet.OLEDB.4.0";
+ //oleDbConnectionStringBuilder.DataSource = @".\Empty.mdb";
+ oleDbConnectionStringBuilder.Provider = "Microsoft.ACE.OLEDB.15.0";
+ oleDbConnectionStringBuilder.DataSource = Helpers.GetTestDirectory() + "\\Model78_MigrationUpdateJet.accdb";
+ return new JetConnection(oleDbConnectionStringBuilder.ToString());
+ }
+
+ [TestMethod]
+ public void MigrationUpdateTest()
+ {
+ using (DbConnection connection = GetConnection())
+ {
+ using (var context = new Context(connection))
+ {
+ string sql = @"
+UPDATE[Students_78] SET [StudentName] = '2'
+WHERE[StudentId] = 1;
+SELECT @@ROWCOUNT; ";
+ context.Database.ExecuteSqlCommand(sql);
+ }
+ }
+ }
+
+ }
+}
diff --git a/test/EFCore.Jet.Integration.Test/TestBase`.cs b/test/EFCore.Jet.Integration.Test/TestBase`.cs
index 6ca156e..7487b1a 100644
--- a/test/EFCore.Jet.Integration.Test/TestBase`.cs
+++ b/test/EFCore.Jet.Integration.Test/TestBase`.cs
@@ -8,6 +8,7 @@ using EntityFrameworkCore.Jet;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -90,6 +91,11 @@ namespace EFCore.Jet.Integration.Test
return databaseCreator;
}
+ public static IMigrator GetDatabaseMigratorService(T context)
+ {
+ return context.GetService();
+ }
+
private static string GetFullExceptionStackMessages(Exception ex)
{
if (ex == null)