Skip to content

Commit

Permalink
* Switching to EFCore 3.1 for this release, due to compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
artiomchi committed Jan 26, 2020
1 parent ab0d7fd commit 4998a72
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Also supports injecting sql command generators to add support for other provider
<VersionPrefix>3.1.0</VersionPrefix>
<PackageReleaseNotes>
v3.1.0
- Referencing EF Core 3.1 only, due to internal namespace changes and compatibility issues with .NET Full Framework
+ Nulable type metadata
+ Adding support for upserting by identity column
+ Splitting the request into multiple queries if the query parameter limit is reached
Expand Down Expand Up @@ -48,25 +49,16 @@ v2.2.0:
<PostBuildEvent>signtool.exe sign /n "$(SignCertificateName)" /fd sha256 /tr "http://timestamp.digicert.com" /td sha256 FlexLabs.EntityFrameworkCore.Upsert.dll</PostBuildEvent>
</PropertyGroup>

<PropertyGroup>
<EFCoreVersion>2.1.0</EFCoreVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
<DefineConstants>$(DefineConstants);EFCORE3</DefineConstants>
<EFCoreVersion>3.0.0</EFCoreVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EFCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19270-01" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 0 additions & 17 deletions src/FlexLabs.EntityFrameworkCore.Upsert/Runners/ProxyExtensions.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,7 @@ public override int Run<TEntity>(DbContext dbContext, IEntityType entityType, IC
{
using var dbCommand = dbContext.Database.GetDbConnection().CreateCommand();
var dbArguments = arguments.Select(a => PrepareDbCommandArgument(dbCommand, relationalTypeMappingSource, a));
#if EFCORE3
result = dbContext.Database.ExecuteSqlRaw(sqlCommand, dbArguments);
#else
result = dbContext.Database.ExecuteSqlCommand(sqlCommand, dbArguments);
#endif
}
return result;
}
Expand All @@ -388,11 +384,7 @@ public override async Task<int> RunAsync<TEntity>(DbContext dbContext, IEntityTy
{
using var dbCommand = dbContext.Database.GetDbConnection().CreateCommand();
var dbArguments = arguments.Select(a => PrepareDbCommandArgument(dbCommand, relationalTypeMappingSource, a));
#if EFCORE3
result = await dbContext.Database.ExecuteSqlRawAsync(sqlCommand, dbArguments).ConfigureAwait(false);
#else
result = await dbContext.Database.ExecuteSqlCommandAsync(sqlCommand, dbArguments).ConfigureAwait(false);
#endif
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static DbContextOptions<TestDbContext> Configure(string connectionString,
options.UseInMemoryDatabase(connectionString);
break;
case DbDriver.Sqlite:
#if !EFCORE3
#if SQLITE_LEGACY
// If we are on Windows platform, we can copy Sqlite 3.24.0 binary to the output directory.
// The dynamic libraries in the current execution path will load first.
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Expand Down
18 changes: 12 additions & 6 deletions test/FlexLabs.EntityFrameworkCore.Upsert.Tests/EF/BasicTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;

namespace FlexLabs.EntityFrameworkCore.Upsert.Tests.EF
{
Expand All @@ -22,8 +24,10 @@ static BasicTest()
DatabaseEngines = new List<TestDbContext.DbDriver>
{
TestDbContext.DbDriver.InMemory,
TestDbContext.DbDriver.Sqlite,
TestDbContext.DbDriver.MSSQL,
#if !NOSQLITE
TestDbContext.DbDriver.Sqlite,
#endif
};
if (IsAppVeyor || RunLocalDockerTests)
DatabaseEngines.AddRange(new[]
Expand Down Expand Up @@ -56,11 +60,13 @@ public class Contexts : IDisposable
private static readonly string AppVeyor_SqlServer_Connection = $"Server=(local)\\SQL2017;Database={Username};User Id=sa;Password={Password}";
private static readonly string AppVeyor_MySql_Connection = $"Server=localhost;Port=3306;Database={Username};Uid=root;Pwd={Password}";

private readonly IMessageSink _diagnosticMessageSink;
private readonly IDictionary<TestDbContext.DbDriver, Process> _processes;
public IDictionary<TestDbContext.DbDriver, DbContextOptions<TestDbContext>> _dataContexts;
public readonly IDictionary<TestDbContext.DbDriver, DbContextOptions<TestDbContext>> _dataContexts;

public Contexts()
public Contexts(IMessageSink diagnosticMessageSink)
{
_diagnosticMessageSink = diagnosticMessageSink;
_processes = new Dictionary<TestDbContext.DbDriver, Process>();
_dataContexts = new Dictionary<TestDbContext.DbDriver, DbContextOptions<TestDbContext>>();

Expand Down Expand Up @@ -102,20 +108,20 @@ private void WaitForConnection(TestDbContext.DbDriver driver, string connectionS
{
bool isSuccess = false;
TestDbContext context = null;
Console.WriteLine("Connecting to " + driver);
_diagnosticMessageSink.OnMessage(new DiagnosticMessage("Connecting to {0}", driver));
try
{
context = new TestDbContext(options);
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
_dataContexts[driver] = options;
isSuccess = true;
Console.WriteLine(" - Connection Successful!");
_diagnosticMessageSink.OnMessage(new DiagnosticMessage("Connection to {0} Successful!", driver));
break;
}
catch (Exception ex)
{
Console.WriteLine(" - EXCEPTION: " + ex.Message);
_diagnosticMessageSink.OnMessage(new DiagnosticMessage("Connecting to {0} failed! Error: {1}", driver, ex.GetBaseException().Message));
System.Threading.Thread.Sleep(1000);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp3.0;netcoreapp3.1;net48</TargetFrameworks>
<LangVersion>latest</LangVersion>
<NoWarn>EF1001</NoWarn>
<IsPackable>false</IsPackable>
<EFCoreVersion>2.2.0</EFCoreVersion>
<EFCoreVersion>3.1.0</EFCoreVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
<DefineConstants>$(DefineConstants);EFCORE3</DefineConstants>
<EFCoreVersion>3.0.0</EFCoreVersion>
<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
<DefineConstants>$(DefineConstants);NOSQLITE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(EFCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(EFCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(EFCoreVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EFCoreVersion)" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="$(EFCoreVersion)" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -28,10 +27,6 @@
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='netcoreapp3.0'">
<PackageReference Include="SQLitePCLRaw.provider.sqlite3.netstandard11" Version="1.1.14" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\FlexLabs.EntityFrameworkCore.Upsert\FlexLabs.EntityFrameworkCore.Upsert.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"methodDisplay": "method",
"maxParallelThreads": 1
"maxParallelThreads": 1,
"diagnosticMessages": true
}

0 comments on commit 4998a72

Please sign in to comment.