2.2-servicing
bubibubi 7 years ago
parent 51b123f110
commit d8773e19c1

@ -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")]
[assembly: AssemblyInformationalVersion("2.2.0-preview5")]

@ -9,10 +9,10 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Allows Jet (Microsoft Access mdb or accdb format files) to be used with Entity Framework Core</description>
<summary>Allows Jet (Microsoft Access mdb or accdb format files) to be used with Entity Framework Core</summary>
<releaseNotes>for EF Core 2.1</releaseNotes>
<releaseNotes>for EF Core 2.2</releaseNotes>
<dependencies>
<group targetFramework="net461">
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="2.1.0" />
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="2.2.0" />
</group>
</dependencies>
</metadata>

@ -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(?<stringSkipCount>@.*)\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>not)?\s*exists\s*\((?<sqlCheckCommand>.+)\)\s*then\s*(?<sqlCommand>.*)$", RegexOptions.IgnoreCase);
/// <summary>
@ -277,7 +276,6 @@ namespace System.Data.Jet
return null;
}
/// <summary>
/// Executes the non query.
/// </summary>
@ -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;

@ -241,6 +241,8 @@
<Compile Include="GearOfWar\Model\Squad.cs" />
<Compile Include="GearOfWar\Model\SquadMission.cs" />
<Compile Include="GearOfWar\Model\Weapon.cs" />
<Compile Include="Model78_MigrationUpdate\Context.cs" />
<Compile Include="Model78_MigrationUpdate\Student.cs" />
<Compile Include="Model04\SqlCeTest.cs" />
<Compile Include="Model16_OwnCollection\SqLiteTest.cs" />
<Compile Include="Model16_OwnCollection\SqlCeTest.cs" />
@ -248,6 +250,7 @@
<Compile Include="Model76_FullCreate\SqlServerTest.cs" />
<Compile Include="Model76_FullCreate\SqlCeTest.cs" />
<Compile Include="Model77_DateTimeOffset\SqlCeTest.cs" />
<Compile Include="Model78_MigrationUpdate\Test.cs" />
<Compile Include="Model_MainTests\Context.cs" />
<Compile Include="Model_MainTests\SqlServerTest.cs" />
<Compile Include="Model_MainTests\SqlCeTest.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<Context>.TryCreateTables(this);
}
public DbSet<Student> Students { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Student>().HasIndex(_ => _.StudentName);
}
}
}

@ -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());
}
}
}

@ -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);
}
}
}
}
}

@ -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<IMigrator>();
}
private static string GetFullExceptionStackMessages(Exception ex)
{
if (ex == null)

Loading…
Cancel
Save