Skip to content

Commit

Permalink
Update to EF Core 6 (#17)
Browse files Browse the repository at this point in the history
Code was updated to 6.x.x version

Co-authored-by: Ilya Belyanskiy <[email protected]>
  • Loading branch information
win7user10 and Ilya Belyanskiy authored Nov 11, 2021
1 parent e5619e7 commit 0594f91
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 57 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EfCoreTriggers is the library to write native SQL triggers using EFCore model bu
[![latest version](https://img.shields.io/nuget/v/Laraue.EfCoreTriggers.Common)](https://www.nuget.org/packages/Laraue.EfCoreTriggers.Common)

### Installation
EfCoreTriggers common package is available on [NuGet](https://www.nuget.org/packages/Laraue.EfCoreTriggers.Common). Install the provider package corresponding to your target database. See the list of providers in the docs for additional databases.
EfCoreTriggers common package is available on Nuget. Version 6.x.x is compatible with .NET6, 1.x.x intended for .NET 5 and no more supported. Install the provider package corresponding to your target database. See the list of providers in the docs for additional databases.

### Configuring DB to use triggers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public static void RememberTriggerProvider<TTriggerProvider>(Action<AvailableCon
_setupProviderConverters = setupConverters;
}

public static ITriggerProvider GetSqlProvider(IModel model)
public static ITriggerProvider GetSqlProvider(IReadOnlyModel model)
{
if (_activeProviderType is null)
{
throw new InvalidOperationException("To use triggers, DB provider should be added");
}

var providerConstructor = _activeProviderType.GetConstructor(new[] { typeof(IModel) });
var providerConstructor = _activeProviderType.GetConstructor(new[] { typeof(IReadOnlyModel) });

if (providerConstructor is null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Common classes EfCoreTriggers packages.</Description>
<RepositoryUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Belyanskiy Ilya</Authors>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>1.0.1</Version>
<PackageProjectUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</PackageProjectUrl>
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;triggers;sql</PackageTags>
<LangVersion>Latest</LangVersion>
<PackageVersion>1.1.1</PackageVersion>
<PackageVersion>6.0.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static IList<SqlOperation> AddCreateTriggerSqlMigration(this IList<SqlOpe
return list;
}

public static IList<SqlOperation> AddDeleteTriggerSqlMigration(this IList<SqlOperation> list, IAnnotation annotation, IModel model)
public static IList<SqlOperation> AddDeleteTriggerSqlMigration(this IList<SqlOperation> list, IAnnotation annotation, IReadOnlyModel model)
{
list.Add(new SqlOperation
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected virtual SqlBuilder GetConstantExpressionSql(ConstantExpression constan
public AvailableConverters Converters { get; } = new ();

/// <inheritdoc />
protected BaseExpressionProvider(IModel model) : base(model)
protected BaseExpressionProvider(IReadOnlyModel model) : base(model)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Laraue.EfCoreTriggers.Common.SqlGeneration
{
public abstract class BaseSqlProvider : BaseExpressionProvider, ITriggerProvider
{
protected BaseSqlProvider(IModel model) : base(model)
protected BaseSqlProvider(IReadOnlyModel model) : base(model)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class EfCoreMetadataRetriever
/// <summary>
/// Model used for generating SQL. From this model takes column names, table names and other meta information.
/// </summary>
protected IModel Model { get; }
protected IReadOnlyModel Model { get; }

/// <summary>
/// Initializes new instance of <see cref="BaseExpressionProvider"/>.
/// </summary>
/// <param name="model"></param>
protected EfCoreMetadataRetriever(IModel model)
protected EfCoreMetadataRetriever(IReadOnlyModel model)
{
Model = model ?? throw new ArgumentNullException(nameof(model));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Generating native MySql triggers through migrations using EFCore entity builder.</Description>
<RepositoryUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Belyanskiy Ilya</Authors>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>1.0.1</Version>
<PackageProjectUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</PackageProjectUrl>
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;triggers;sql;MySql</PackageTags>
<LangVersion>Latest</LangVersion>
<PackageVersion>1.1.1</PackageVersion>
<PackageVersion>6.0.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Laraue.EfCoreTriggers.MySql/MySqlProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Laraue.EfCoreTriggers.MySql
{
public class MySqlProvider : BaseSqlProvider
{
public MySqlProvider(IModel model) : base(model)
public MySqlProvider(IReadOnlyModel model) : base(model)
{
AddConverter(new ConcatStringViaConcatFuncConverter());
AddConverter(new StringToUpperViaUpperFuncConverter());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Generating native PostgreSql triggers through migrations using EFCore entity builder.</Description>
<RepositoryUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Belyanskiy Ilya</Authors>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>1.0.1</Version>
<PackageProjectUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</PackageProjectUrl>
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;triggers;sql;PostgreSql</PackageTags>
<LangVersion>Latest</LangVersion>
<PackageVersion>1.1.1</PackageVersion>
<PackageVersion>6.0.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Laraue.EfCoreTriggers.PostgreSql/PostgreSqlProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Laraue.EfCoreTriggers.PostgreSql
{
public class PostgreSqlProvider : BaseSqlProvider
{
public PostgreSqlProvider(IModel model) : base(model)
public PostgreSqlProvider(IReadOnlyModel model) : base(model)
{
AddConverter(new ConcatStringViaConcatFuncConverter());
AddConverter(new StringToUpperViaUpperFuncConverter());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Generating native SqlLite triggers through migrations using EFCore entity builder.</Description>
<RepositoryUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Belyanskiy Ilya</Authors>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>1.0.1</Version>
<PackageProjectUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</PackageProjectUrl>
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;triggers;sql;SqlLite</PackageTags>
<LangVersion>Latest</LangVersion>
<PackageVersion>1.1.1</PackageVersion>
<PackageVersion>6.0.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Laraue.EfCoreTriggers.SqlLite/SqlLiteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Laraue.EfCoreTriggers.SqlLite
{
public class SqlLiteProvider : BaseSqlProvider
{
public SqlLiteProvider(IModel model) : base(model)
public SqlLiteProvider(IReadOnlyModel model) : base(model)
{
AddConverter(new ConcatStringViaDoubleVerticalLineConverter());
AddConverter(new StringToUpperViaUpperFuncConverter());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Generating native SqlServer triggers through migrations using EFCore entity builder.</Description>
<RepositoryUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Belyanskiy Ilya</Authors>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>1.0.1</Version>
<PackageProjectUrl>https://github.com/win7user10/Laraue.EfCoreTriggers</PackageProjectUrl>
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;triggers;sql;SqlServer</PackageTags>
<LangVersion>Latest</LangVersion>
<PackageVersion>1.1.1</PackageVersion>
<PackageVersion>6.0.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Laraue.EfCoreTriggers.SqlServer/SqlServerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Laraue.EfCoreTriggers.SqlServer
{
public class SqlServerProvider : BaseSqlProvider
{
public SqlServerProvider(IModel model) : base(model)
public SqlServerProvider(IReadOnlyModel model) : base(model)
{
AddConverter(new ConcatStringViaPlusConverter());
AddConverter(new StringToUpperViaUpperFuncConverter());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -18,10 +18,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -17,10 +17,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -18,10 +18,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -18,10 +18,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="5.0.2" />
<PackageReference Include="linq2db.EntityFrameworkCore" Version="5.8.0" />
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0-rc.1" />
<PackageReference Include="linq2db.EntityFrameworkCore" Version="6.5.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.categories" Version="2.0.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Laraue.EfCoreTriggers.Tests.Tests
public class ConditionGeneratingTests
{
private readonly ITriggerProvider _provider;
private readonly IModel _model;
private readonly IMutableModel _model;

public ConditionGeneratingTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class InvalidOperationTests
public InvalidOperationTests()
{
var modelBuilder = new ModelBuilder();
IModel model = modelBuilder.Model;
IReadOnlyModel model = modelBuilder.Model;
_provider = new MySqlProvider(model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public SetupProviderConverterTests()
modelBuilder.Entity<Transaction>()
.Property<string>("Description");

IModel model = modelBuilder.Model;
IReadOnlyModel model = modelBuilder.Model;
_provider = new MySqlProvider(model);
}

Expand Down

0 comments on commit 0594f91

Please sign in to comment.