Skip to content

Commit

Permalink
Support for Entity Framework v8.0 (#126)
Browse files Browse the repository at this point in the history
* Added test project for Entity Framework Core v8.0.0
* Relaxed package constraints
* Added version support description
* Fixed warnings
* Updated pipelines
  • Loading branch information
aivascu authored Nov 26, 2023
1 parent ed9a813 commit 658d1ec
Show file tree
Hide file tree
Showing 29 changed files with 434 additions and 298 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
with:
Expand Down
34 changes: 19 additions & 15 deletions EntityFrameworkCore.AutoFixture.sln
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
# Visual Studio Version 17
VisualStudioVersion = 17.8.34316.72
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".sln", ".sln", "{41F502FD-F586-4510-9E54-96A81EE0EBBE}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
README.md = README.md
Common.props = Common.props
Common.Tests.props = Common.Tests.props
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture", "src\EntityFrameworkCore.AutoFixture\EntityFrameworkCore.AutoFixture.csproj", "{34A29C69-9C15-4C1E-833D-6F9792EAED7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "build\_build.csproj", "{240F3B9C-540A-4500-84E2-8F406D71BB8A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{240F3B9C-540A-4500-84E2-8F406D71BB8A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.EF2.Tests", "tests\EntityFrameworkCore.AutoFixture.EF2.Tests\EntityFrameworkCore.AutoFixture.EF2.Tests.csproj", "{9F91E002-8D3D-4050-AC8F-1867362FC721}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.AutoFixture.Tests", "tests\EntityFrameworkCore.AutoFixture.Tests\EntityFrameworkCore.AutoFixture.Tests.csproj", "{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.EF3.Tests", "tests\EntityFrameworkCore.AutoFixture.EF3.Tests\EntityFrameworkCore.AutoFixture.EF3.Tests.csproj", "{1FB77B86-0731-4561-A85C-F8128AB3CEF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.AutoFixture.EF2.Tests", "tests\EntityFrameworkCore.AutoFixture.EF2.Tests\EntityFrameworkCore.AutoFixture.EF2.Tests.csproj", "{9F91E002-8D3D-4050-AC8F-1867362FC721}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.EF5.Tests", "tests\EntityFrameworkCore.AutoFixture.EF5.Tests\EntityFrameworkCore.AutoFixture.EF5.Tests.csproj", "{A03F7586-05F7-45AD-847D-02C1DB6E0FE7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.AutoFixture.EF3.Tests", "tests\EntityFrameworkCore.AutoFixture.EF3.Tests\EntityFrameworkCore.AutoFixture.EF3.Tests.csproj", "{1FB77B86-0731-4561-A85C-F8128AB3CEF7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.EF6.Tests", "tests\EntityFrameworkCore.AutoFixture.EF6.Tests\EntityFrameworkCore.AutoFixture.EF6.Tests.csproj", "{41937419-0EB6-4AEB-AFF7-F613C5315751}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.AutoFixture.EF5.Tests", "tests\EntityFrameworkCore.AutoFixture.EF5.Tests\EntityFrameworkCore.AutoFixture.EF5.Tests.csproj", "{A03F7586-05F7-45AD-847D-02C1DB6E0FE7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.EF7.Tests", "tests\EntityFrameworkCore.AutoFixture.EF7.Tests\EntityFrameworkCore.AutoFixture.EF7.Tests.csproj", "{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.AutoFixture.EF6.Tests", "tests\EntityFrameworkCore.AutoFixture.EF6.Tests\EntityFrameworkCore.AutoFixture.EF6.Tests.csproj", "{41937419-0EB6-4AEB-AFF7-F613C5315751}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.Tests", "tests\EntityFrameworkCore.AutoFixture.Tests\EntityFrameworkCore.AutoFixture.Tests.csproj", "{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -39,10 +41,6 @@ Global
{34A29C69-9C15-4C1E-833D-6F9792EAED7C}.Release|Any CPU.Build.0 = Release|Any CPU
{240F3B9C-540A-4500-84E2-8F406D71BB8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{240F3B9C-540A-4500-84E2-8F406D71BB8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.Build.0 = Release|Any CPU
{9F91E002-8D3D-4050-AC8F-1867362FC721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F91E002-8D3D-4050-AC8F-1867362FC721}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F91E002-8D3D-4050-AC8F-1867362FC721}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -59,12 +57,18 @@ Global
{41937419-0EB6-4AEB-AFF7-F613C5315751}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41937419-0EB6-4AEB-AFF7-F613C5315751}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41937419-0EB6-4AEB-AFF7-F613C5315751}.Release|Any CPU.Build.0 = Release|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.Build.0 = Release|Any CPU
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CBF14D09-229F-49A4-A7CA-7975072528FB}
EndGlobalSection
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
Unlike other libraries for faking EF contexts, **EntityFrameworkCore.AutoFixture** does not use mocking frameworks or
dynamic proxies in to create database contexts, instead it uses the actual database [providers](https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/). This ensures the tests will behave a lot more similar to the code in the production environment, with little to no effort.

### Supported versions

The current implementation supports all `Microsoft.EntityFrameworkCore` packages starting from `v2.0.0` and `AutoFixture` starting from `v4.4.0`, however because the constraints are so low you will have to install the latest versiosn of `Microsoft.EntityFrameworkCore` and `AutoFixture` packages yourself, alongside this package.

Make sure to keep in sync the versions of packages used in production and test code. Meaning that if you use `Microsoft.EntityFrameworkCore.SqlServer` of version `v7.0.14`, you need to use the equivalent version of `Microsoft.EntityFrameworkCore.Sqlite`.

| Integration | Package |
|-------------|----------------------------------------|
| SQLite | Microsoft.EntityFrameworkCore.Sqlite |
| In-Memory | Microsoft.EntityFrameworkCore.InMemory |

#### :warning: .NET Standard 2.0 in EF Core v3.0.x :warning:

Entity Framework Core `v3.0.0` - `v3.0.3` are targeting `netstandard2.1`, which means they are not compatible with
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.props" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -35,11 +35,4 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net6.'))">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="6.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,84 +1,83 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace EntityFrameworkCore.AutoFixture.Tests.Migrations
namespace EntityFrameworkCore.AutoFixture.Tests.Migrations;

public partial class InitialMigration : Migration
{
public partial class InitialMigration : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});

migrationBuilder.CreateTable(
name: "Items",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Price = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Items",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Price = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.Id);
});

migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Count = table.Column<int>(nullable: false),
CustomerId = table.Column<Guid>(nullable: false),
ItemId = table.Column<Guid>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Items_ItemId",
column: x => x.ItemId,
principalTable: "Items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Count = table.Column<int>(nullable: false),
CustomerId = table.Column<Guid>(nullable: false),
ItemId = table.Column<Guid>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Items_ItemId",
column: x => x.ItemId,
principalTable: "Items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_Orders_CustomerId",
table: "Orders",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_Orders_CustomerId",
table: "Orders",
column: "CustomerId");

migrationBuilder.CreateIndex(
name: "IX_Orders_ItemId",
table: "Orders",
column: "ItemId");
}
migrationBuilder.CreateIndex(
name: "IX_Orders_ItemId",
table: "Orders",
column: "ItemId");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");

migrationBuilder.DropTable(
name: "Customers");
migrationBuilder.DropTable(
name: "Customers");

migrationBuilder.DropTable(
name: "Items");
}
migrationBuilder.DropTable(
name: "Items");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

<PackageReference Include="Moq" Version="4.14.5" />

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.27" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.27" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.27" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.27" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.32" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.32" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.32" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.32" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 658d1ec

Please sign in to comment.