Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Dependencies.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<DotNetVersion>[9.0.0,9.0.999]</DotNetVersion>
<EFCoreVersion>[9.0.0,9.0.999]</EFCoreVersion>
<MSLibVersion>[9.0.0,9.0.999]</MSLibVersion>
<DotNetVersion>[9.0.4,9.0.999]</DotNetVersion>
<EFCoreVersion>[9.0.4,9.0.999]</EFCoreVersion>
<MSLibVersion>[9.0.4,9.0.999]</MSLibVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,17 +28,17 @@
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="$(MSLibVersion)" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Update="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Update="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Update="coverlet.collector" Version="6.0.2" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Update="MSTest.TestAdapter" Version="3.8.3" />
<PackageReference Update="MSTest.TestFramework" Version="3.8.3" />
<PackageReference Update="coverlet.collector" Version="6.0.4" />
<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />

<!-- EFCore.Jet.FunctionalTests -->
<PackageReference Update="xunit.core" Version="2.9.2"/>
<PackageReference Update="xunit.assert" Version="2.9.2" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Update="xunit.runner.console" Version="2.9.2" />
<PackageReference Update="xunit.core" Version="2.9.3"/>
<PackageReference Update="xunit.assert" Version="2.9.3" />
<PackageReference Update="xunit.runner.visualstudio" Version="3.0.2" />
<PackageReference Update="xunit.runner.console" Version="2.9.3" />
<PackageReference Update="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MSLibVersion)" />
<PackageReference Update="NetTopologySuite" Version="2.5.0" />
<PackageReference Update="System.ComponentModel.TypeConverter" Version="4.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Company>CirrusRed</Company>
<Copyright>Copyright © 2017-$([System.DateTime]::Now.Year) CirrusRed</Copyright>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<LangVersion>12.0</LangVersion>
<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>
<DebugType>portable</DebugType>
<IsPackable>False</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
correctly.
-->
<VersionPrefix>9.0.0</VersionPrefix>
<PreReleaseVersionLabel>beta</PreReleaseVersionLabel>
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
<PreReleaseVersionIteration>0</PreReleaseVersionIteration>

<!--
The following properties will automatically be set by CI builds when appropriate:
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "9.0.100",
"allowPrerelease": true,
"allowPrerelease": false,
"rollForward": "latestFeature"
}
}
15 changes: 14 additions & 1 deletion src/EFCore.Jet.Data/JetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,26 @@ protected virtual int ExecuteNonQueryCore()

if (!CheckExists(InnerCommand.CommandText, out var newCommandText))
return 0;
bool isexistssql = newCommandText != InnerCommand.CommandText && (InnerCommand.CommandText.StartsWith("IF EXISTS",StringComparison.OrdinalIgnoreCase) || InnerCommand.CommandText.StartsWith("IF NOT EXISTS", StringComparison.OrdinalIgnoreCase));

InnerCommand.CommandText = newCommandText;

InlineTopParameters();
FixParameters();

_connection.RowCount = InnerCommand.ExecuteNonQuery();
try
{
_connection.RowCount = InnerCommand.ExecuteNonQuery();
}
catch (DbException e)
{
if (!e.Message.Contains("already exists") || !isexistssql)
{
throw;
}

return 0;
}

// For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.
// For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
Expand Down
54 changes: 54 additions & 0 deletions src/EFCore.Jet/Migrations/Internal/JetHistoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,59 @@ public override string GetEndIfScript()
{
throw new NotSupportedException(JetStrings.MigrationScriptGenerationNotSupported);
}

public override IReadOnlyList<HistoryRow> GetAppliedMigrations()
{
var rows = new List<HistoryRow>();
//Note the exists check opens a new connection with adox/dao. If doing within a transaction it wont find the table until the transaction is committed. Just read anyway
//No op if the table does not exist
//if (Exists())
{
var command = Dependencies.RawSqlCommandBuilder.Build(GetAppliedMigrationsSql);

using var reader = command.ExecuteReader(
new RelationalCommandParameterObject(
Dependencies.Connection,
null,
null,
Dependencies.CurrentContext.Context,
Dependencies.CommandLogger, CommandSource.Migrations));
while (reader.Read())
{
rows.Add(new HistoryRow(reader.DbDataReader.GetString(0), reader.DbDataReader.GetString(1)));
}
}

return rows;
}

public override async Task<IReadOnlyList<HistoryRow>> GetAppliedMigrationsAsync(CancellationToken cancellationToken = new CancellationToken())
{
var rows = new List<HistoryRow>();
//Note the exists check opens a new connection with adox/dao. If doing within a transaction it wont find the table until the transaction is committed. Just read anyway
//No op if the table does not exist
//if (await ExistsAsync(cancellationToken).ConfigureAwait(false))
{
var command = Dependencies.RawSqlCommandBuilder.Build(GetAppliedMigrationsSql);

var reader = await command.ExecuteReaderAsync(
new RelationalCommandParameterObject(
Dependencies.Connection,
null,
null,
Dependencies.CurrentContext.Context,
Dependencies.CommandLogger, CommandSource.Migrations),
cancellationToken).ConfigureAwait(false);

await using var _ = reader.ConfigureAwait(false);

while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false))
{
rows.Add(new HistoryRow(reader.DbDataReader.GetString(0), reader.DbDataReader.GetString(1)));
}
}

return rows;
}
}
}
33 changes: 22 additions & 11 deletions src/EFCore.Jet/Migrations/Internal/JetMigrationCommandExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EntityFrameworkCore.Jet.Data.JetStoreSchemaDefinition;
using EntityFrameworkCore.Jet.Data;
using EntityFrameworkCore.Jet.Data.JetStoreSchemaDefinition;
using Microsoft.EntityFrameworkCore.Migrations.Internal;

namespace EntityFrameworkCore.Jet.Migrations.Internal
Expand All @@ -19,12 +20,18 @@ public override int ExecuteNonQuery(
System.Data.IsolationLevel? isolationLevel = null)
{
var batches = CreateMigrationBatches(migrationCommands);
int output = 0;

foreach (var batch in batches)
{
base.ExecuteNonQuery(batch, connection, executionState, true, isolationLevel);
output += base.ExecuteNonQuery(batch.Item1, connection, executionState, true, isolationLevel);
if (batch.Item2) Thread.Sleep(4000);//Wait for adox/dao to complete
}

return -1;
if (connection.CurrentTransaction != null)
{
connection.CurrentTransaction.Commit();
}
return output;
}

public override async Task<int> ExecuteNonQueryAsync(
Expand All @@ -38,27 +45,31 @@ public override async Task<int> ExecuteNonQueryAsync(
var batches = CreateMigrationBatches(migrationCommands);
foreach (var batch in batches)
{
await base.ExecuteNonQueryAsync(batch, connection, executionState, true, isolationLevel, cancellationToken);
await base.ExecuteNonQueryAsync(batch.Item1, connection, executionState, true, isolationLevel, cancellationToken);
if (batch.Item2) Thread.Sleep(4000);
}
if (connection.CurrentTransaction != null)
{
await connection.CurrentTransaction.CommitAsync(cancellationToken);
}

return -1;
}

List<IReadOnlyList<MigrationCommand>> CreateMigrationBatches(IReadOnlyList<MigrationCommand> migrationCommands)
List<(IReadOnlyList<MigrationCommand>,bool)> CreateMigrationBatches(IReadOnlyList<MigrationCommand> migrationCommands)
{
//create new batch if JetSchemaOperationsHandling.IsDatabaseOperation is true otherwise had to current batch
var migrationBatches = new List<IReadOnlyList<MigrationCommand>>();
var migrationBatches = new List<(IReadOnlyList<MigrationCommand>, bool)>();
var currentBatch = new List<MigrationCommand>();
foreach (var migrationCommand in migrationCommands)
{
if (JetSchemaOperationsHandling.IsDatabaseOperation(migrationCommand.CommandText))
{
if (currentBatch.Count != 0)
{
migrationBatches.Add(currentBatch);
migrationBatches.Add((currentBatch,false));
currentBatch = [];
}
migrationBatches.Add([migrationCommand]);
migrationBatches.Add(([migrationCommand],true));
}
else
{
Expand All @@ -67,7 +78,7 @@ List<IReadOnlyList<MigrationCommand>> CreateMigrationBatches(IReadOnlyList<Migra
}
if (currentBatch.Count != 0)
{
migrationBatches.Add(currentBatch);
migrationBatches.Add((currentBatch,false));
}
return migrationBatches;
}
Expand Down
9 changes: 2 additions & 7 deletions src/EFCore.Jet/Storage/Internal/JetDateOnlyTypeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,9 @@ protected virtual DateTime ConvertToDateTimeCompatibleValue(object value)

private static DateTime CheckDateTimeValue(DateTime dateTime)
{
if (dateTime < JetConfiguration.TimeSpanOffset)
if (dateTime != default && dateTime < new DateTime(100,1,1))
{
if (dateTime != default)
{
throw new InvalidOperationException($"The {nameof(DateTime)} value '{dateTime}' is smaller than the minimum supported value of '{JetConfiguration.TimeSpanOffset}'.");
}

dateTime = JetConfiguration.TimeSpanOffset;
throw new InvalidOperationException($"The {nameof(DateTime)} value '{dateTime}' is smaller than the minimum supported value of '{new DateTime(100, 1, 1)}'.");
}

return dateTime;
Expand Down
2 changes: 1 addition & 1 deletion test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<NoWarn>$(NoWarn);CA1707;1591;xUnit1000;xUnit1003;xUnit1004;xUnit1010;xUnit1013;xUnit1026;xUnit2013;xUnit1024;NU1903;EF1001</NoWarn>
<LangVersion>preview</LangVersion>
<LangVersion>13.0</LangVersion>
<DefaultNetCoreTargetFramework>net9.0</DefaultNetCoreTargetFramework>
<!-- TODO: Change to "'$(FixedTestOrder)' != 'true'" once test suite is stable. -->
<DefineConstants Condition="'$(FixedTestOrder)' != 'false'">$(DefineConstants);FIXED_TEST_ORDER</DefineConstants>
Expand Down
Loading
Loading