Skip to content

Commit

Permalink
EFCore 7.0 and around
Browse files Browse the repository at this point in the history
  • Loading branch information
cincuranet committed Aug 27, 2023
1 parent f169563 commit 3739000
Show file tree
Hide file tree
Showing 123 changed files with 5,619 additions and 587 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: .NET 6.0
- name: .NET 7.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Build
run: |
Expand Down
2 changes: 1 addition & 1 deletion header.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ gci $baseDir -Recurse -Filter *.cs | %{
}
}
if (!$started) {
//echo $_.FullName
#echo $_.FullName
return
}

Expand Down
2 changes: 1 addition & 1 deletion include.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ function Check-ExitCode() {
}

function Get-UsedTargetFramework() {
return 'net6.0'
return 'net7.0'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<!-- Figure out a way to run it on net4.8 (FirebirdSql.Data.TestsBase uses IAsyncDisposable) -->
<TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<SkipSourceLink>true</SkipSourceLink>
Expand All @@ -11,7 +12,7 @@
<OutputType>Exe</OutputType>
<StartupObject>FirebirdSql.Data.TestsBase.Program</StartupObject>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<ItemGroup Condition="'$(TargetFramework)'=='net7.0'">
<None Remove="app.config" />
</ItemGroup>
<ItemGroup>
Expand All @@ -25,7 +26,7 @@
<ProjectReference Include="..\EntityFramework.Firebird\EntityFramework.Firebird.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="..\FirebirdSql.Data.TestsBase\FirebirdSql.Data.TestsBase.projitems" Label="Shared" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class EntityFrameworkTestsBase : FbTestsBase
{
static EntityFrameworkTestsBase()
{
#if NET6_0_OR_GREATER
#if !NETFRAMEWORK
System.Data.Common.DbProviderFactories.RegisterFactory(FbProviderServices.ProviderInvariantName, FirebirdClientFactory.Instance);
#endif
DbConfiguration.SetConfiguration(new FbTestDbContext.Conf());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<PropertyGroup>
<AssemblyTitle>NETProvider - Entity Framework Provider</AssemblyTitle>
<Copyright>(c) 2014-2021</Copyright>
<Copyright>(c) 2014-2023</Copyright>
</PropertyGroup>
<PropertyGroup>
<PackageId>EntityFramework.Firebird</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/EntityFramework.Firebird/SqlGen/SqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2552,7 +2552,7 @@ private static ISqlFragment HandleCanonicalFunctionBitwiseAnd(SqlGenerator sqlge

private static ISqlFragment HandleCanonicalFunctionBitwiseNot(SqlGenerator sqlgen, DbFunctionExpression e)
{
throw new NotSupportedException("BitwiseNot is not supported by Firebird.");
return sqlgen.HandleFunctionDefaultGivenName(e, "BIN_NOT");
}

private static ISqlFragment HandleCanonicalFunctionBitwiseOr(SqlGenerator sqlgen, DbFunctionExpression e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<SkipSourceLink>true</SkipSourceLink>
Expand All @@ -22,6 +22,6 @@
</ItemGroup>
<Import Project="..\FirebirdSql.Data.TestsBase\FirebirdSql.Data.TestsBase.projitems" Label="Shared" />
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net48;netstandard2.0;netstandard2.1;net5.0;net6.0;net7.0</TargetFrameworks>
<AssemblyName>FirebirdSql.Data.FirebirdClient</AssemblyName>
<RootNamespace>FirebirdSql.Data</RootNamespace>
<SignAssembly>true</SignAssembly>
Expand All @@ -11,7 +11,7 @@
</PropertyGroup>
<PropertyGroup>
<AssemblyTitle>NETProvider - ADO.NET Data Provider</AssemblyTitle>
<Copyright>(c) 2002-2021</Copyright>
<Copyright>(c) 2002-2023</Copyright>
</PropertyGroup>
<PropertyGroup>
<PackageId>FirebirdSql.Data.FirebirdClient</PackageId>
Expand Down Expand Up @@ -51,6 +51,8 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net7.0'">
</ItemGroup>
<ItemGroup>
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/FirebirdSql.Data.FirebirdClient/Logging/LogMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,4 @@ public static void TransactionRolledBackRetaining(IFbLogger log, FbTransaction t
}

static bool IsNullParameterValue(object value) => value == DBNull.Value || value == null;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<SkipSourceLink>true</SkipSourceLink>
<AssemblyName>FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests</AssemblyName>
<RootNamespace>FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\FirebirdSql.Data.TestsBase\FirebirdSql.Data.TestsBase.snk</AssemblyOriginatorKeyFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="6.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="7.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,23 @@ public static void SimpleTableNames(ModelBuilder modelBuilder)
{
if (entityType.BaseType != null)
continue;
var name = new string(entityType.GetTableName().Where(char.IsUpper).ToArray());
entityType.SetTableName(Simplify(entityType.GetTableName()));
foreach (var property in entityType.GetProperties())
{
property.SetColumnName(Simplify(property.Name));
}
}

string Simplify(string name)
{
name = new string(name.Where(char.IsUpper).ToArray());
var cnt = 1;
while (names.Contains(name))
{
name += cnt++;
}
names.Add(name);
entityType.SetTableName(name);
return name;
}
}

Expand All @@ -76,4 +85,27 @@ public static void SetPrimaryKeyGeneration(ModelBuilder modelBuilder, FbValueGen
}
}
}

public static void ShortenMM(ModelBuilder modelBuilder)
{
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
entityType.SetTableName(Shorten(entityType.ShortName()));
foreach (var property in entityType.GetProperties())
{
property.SetColumnName(Shorten(property.Name));
}
}

static string Shorten(string s)
{
return s
.Replace("UnidirectionalEntity", "UE")
.Replace("Unidirectional", "U")
.Replace("JoinOneToThree", "J1_3")
.Replace("EntityTableSharing", "ETS")
.Replace("GeneratedKeys", "GK")
.Replace("ImplicitManyToMany", "IMM");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ public LongExecutionTheoryAttribute()
Skip = "Long execution.";
}
}

public class NotSupportedByProviderFactAttribute : FactAttribute
{
public NotSupportedByProviderFactAttribute()
{
Skip = "Not supported by provider.";
}
}
public class NotSupportedByProviderTheoryAttribute : TheoryAttribute
{
public NotSupportedByProviderTheoryAttribute()
{
Skip = "Not supported by provider.";
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
using Xunit;
/*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* All Rights Reserved.
*/

[assembly: CollectionBehavior(DisableTestParallelization = true)]
//$Authors = Jiri Cincura ([email protected])

using Xunit;

[assembly: CollectionBehavior(DisableTestParallelization = true)]
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,12 @@ public MigrationsFbTest(MigrationsFbFixture fixture)
[Fact(Skip = SkipReason)]
public override Task Rename_index() => base.Rename_index();

[Fact(Skip = SkipReason)]
public override Task Add_primary_key() => base.Add_primary_key();

[Fact(Skip = SkipReason)]
public override Task Add_primary_key_with_name() => base.Add_primary_key_with_name();

[Fact(Skip = SkipReason)]
public override Task Add_primary_key_composite_with_name() => base.Add_primary_key_composite_with_name();

[Fact(Skip = SkipReason)]
public override Task Drop_primary_key() => base.Drop_primary_key();

[Fact(Skip = SkipReason)]
public override Task Add_foreign_key() => base.Add_foreign_key();

Expand Down Expand Up @@ -294,13 +288,49 @@ public MigrationsFbTest(MigrationsFbFixture fixture)
[Fact(Skip = SkipReason)]
public override Task SqlOperation() => base.SqlOperation();

[Fact(Skip = SkipReason)]
public override Task Add_primary_key_int() => base.Add_primary_key_int();

[Fact(Skip = SkipReason)]
public override Task Add_primary_key_string() => base.Add_primary_key_string();

[Fact(Skip = SkipReason)]
public override Task Alter_column_change_computed_recreates_indexes() => base.Alter_column_change_computed_recreates_indexes();

[Fact(Skip = SkipReason)]
public override Task Alter_column_make_required_with_null_data() => base.Alter_column_make_required_with_null_data();

[Fact(Skip = SkipReason)]
public override Task Alter_index_change_sort_order() => base.Alter_index_change_sort_order();

[Fact(Skip = SkipReason)]
public override Task Alter_index_make_unique() => base.Alter_index_make_unique();

[Fact(Skip = SkipReason)]
public override Task Create_index_descending() => base.Create_index_descending();

[Fact(Skip = SkipReason)]
public override Task Create_index_descending_mixed() => base.Create_index_descending_mixed();

[Fact(Skip = SkipReason)]
public override Task Create_sequence_long() => base.Create_sequence_long();

[Fact(Skip = SkipReason)]
public override Task Create_sequence_short() => base.Create_sequence_short();

[Fact(Skip = SkipReason)]
public override Task Drop_primary_key_int() => base.Drop_primary_key_int();

[Fact(Skip = SkipReason)]
public override Task Drop_primary_key_string() => base.Drop_primary_key_string();

public class MigrationsFbFixture : MigrationsFixtureBase
{
protected override string StoreName => nameof(MigrationsFbTest);

protected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;

public override TestHelpers TestHelpers => FbTestHelpers.Instance;
public override RelationalTestHelpers TestHelpers => FbTestHelpers.Instance;

protected override IServiceCollection AddServices(IServiceCollection serviceCollection)
#pragma warning disable EF1001
Expand Down
Loading

0 comments on commit 3739000

Please sign in to comment.