Skip to content

Commit 658d1ec

Browse files
authored
Support for Entity Framework v8.0 (#126)
* Added test project for Entity Framework Core v8.0.0 * Relaxed package constraints * Added version support description * Fixed warnings * Updated pipelines
1 parent ed9a813 commit 658d1ec

29 files changed

+434
-298
lines changed

.github/workflows/continuous.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
3.1.x
4242
5.0.x
4343
6.0.x
44+
7.0.x
45+
8.0.x
4446
- name: Cache .nuke/temp, ~/.nuget/packages
4547
uses: actions/cache@v2
4648
with:

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
3.1.x
3737
5.0.x
3838
6.0.x
39+
7.0.x
40+
8.0.x
3941
- name: Cache .nuke/temp, ~/.nuget/packages
4042
uses: actions/cache@v2
4143
with:

EntityFrameworkCore.AutoFixture.sln

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29409.12
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34316.72
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".sln", ".sln", "{41F502FD-F586-4510-9E54-96A81EE0EBBE}"
77
ProjectSection(SolutionItems) = preProject
88
.editorconfig = .editorconfig
99
.gitattributes = .gitattributes
1010
.gitignore = .gitignore
11-
README.md = README.md
1211
Common.props = Common.props
1312
Common.Tests.props = Common.Tests.props
13+
README.md = README.md
1414
EndProjectSection
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture", "src\EntityFrameworkCore.AutoFixture\EntityFrameworkCore.AutoFixture.csproj", "{34A29C69-9C15-4C1E-833D-6F9792EAED7C}"
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "build\_build.csproj", "{240F3B9C-540A-4500-84E2-8F406D71BB8A}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{240F3B9C-540A-4500-84E2-8F406D71BB8A}"
19+
EndProject
20+
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}"
1921
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.AutoFixture.Tests", "tests\EntityFrameworkCore.AutoFixture.Tests\EntityFrameworkCore.AutoFixture.Tests.csproj", "{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}"
22+
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}"
2123
EndProject
22-
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}"
24+
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}"
2325
EndProject
24-
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}"
26+
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}"
2527
EndProject
26-
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}"
28+
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}"
2729
EndProject
28-
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}"
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.AutoFixture.Tests", "tests\EntityFrameworkCore.AutoFixture.Tests\EntityFrameworkCore.AutoFixture.Tests.csproj", "{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}"
2931
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,10 +41,6 @@ Global
3941
{34A29C69-9C15-4C1E-833D-6F9792EAED7C}.Release|Any CPU.Build.0 = Release|Any CPU
4042
{240F3B9C-540A-4500-84E2-8F406D71BB8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4143
{240F3B9C-540A-4500-84E2-8F406D71BB8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
42-
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43-
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
44-
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
45-
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.Build.0 = Release|Any CPU
4644
{9F91E002-8D3D-4050-AC8F-1867362FC721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4745
{9F91E002-8D3D-4050-AC8F-1867362FC721}.Debug|Any CPU.Build.0 = Debug|Any CPU
4846
{9F91E002-8D3D-4050-AC8F-1867362FC721}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -59,12 +57,18 @@ Global
5957
{41937419-0EB6-4AEB-AFF7-F613C5315751}.Debug|Any CPU.Build.0 = Debug|Any CPU
6058
{41937419-0EB6-4AEB-AFF7-F613C5315751}.Release|Any CPU.ActiveCfg = Release|Any CPU
6159
{41937419-0EB6-4AEB-AFF7-F613C5315751}.Release|Any CPU.Build.0 = Release|Any CPU
60+
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61+
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
62+
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
63+
{476C1F2E-CE1B-43D0-9076-9DF78DC69DF9}.Release|Any CPU.Build.0 = Release|Any CPU
64+
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65+
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Debug|Any CPU.Build.0 = Debug|Any CPU
66+
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Release|Any CPU.ActiveCfg = Release|Any CPU
67+
{5F2EB641-3B94-42D4-A09B-C02B5C1B0D66}.Release|Any CPU.Build.0 = Release|Any CPU
6268
EndGlobalSection
6369
GlobalSection(SolutionProperties) = preSolution
6470
HideSolutionNode = FALSE
6571
EndGlobalSection
66-
GlobalSection(NestedProjects) = preSolution
67-
EndGlobalSection
6872
GlobalSection(ExtensibilityGlobals) = postSolution
6973
SolutionGuid = {CBF14D09-229F-49A4-A7CA-7975072528FB}
7074
EndGlobalSection

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
Unlike other libraries for faking EF contexts, **EntityFrameworkCore.AutoFixture** does not use mocking frameworks or
1212
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.
1313

14+
### Supported versions
15+
16+
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.
17+
18+
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`.
19+
20+
| Integration | Package |
21+
|-------------|----------------------------------------|
22+
| SQLite | Microsoft.EntityFrameworkCore.Sqlite |
23+
| In-Memory | Microsoft.EntityFrameworkCore.InMemory |
24+
1425
#### :warning: .NET Standard 2.0 in EF Core v3.0.x :warning:
1526

1627
Entity Framework Core `v3.0.0` - `v3.0.3` are targeting `netstandard2.1`, which means they are not compatible with

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.100",
3+
"version": "8.0.100",
44
"rollForward": "latestFeature"
55
}
66
}

src/EntityFrameworkCore.AutoFixture/EntityFrameworkCore.AutoFixture.csproj

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\..\Common.props" />
33

44
<PropertyGroup>
5-
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
5+
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
66
<LangVersion>latest</LangVersion>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<PackageReference Include="AutoFixture" Version="4.4.0" />
12-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
12+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
@@ -35,11 +35,4 @@
3535
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
3636
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="5.0.0" />
3737
</ItemGroup>
38-
39-
<ItemGroup Condition="$(TargetFramework.StartsWith('net6.'))">
40-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
41-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
42-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
43-
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="6.0.0" />
44-
</ItemGroup>
4538
</Project>
Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,83 @@
11
using System;
22
using Microsoft.EntityFrameworkCore.Migrations;
33

4-
namespace EntityFrameworkCore.AutoFixture.Tests.Migrations
4+
namespace EntityFrameworkCore.AutoFixture.Tests.Migrations;
5+
6+
public partial class InitialMigration : Migration
57
{
6-
public partial class InitialMigration : Migration
8+
protected override void Up(MigrationBuilder migrationBuilder)
79
{
8-
protected override void Up(MigrationBuilder migrationBuilder)
9-
{
10-
migrationBuilder.CreateTable(
11-
name: "Customers",
12-
columns: table => new
13-
{
14-
Id = table.Column<Guid>(nullable: false),
15-
Name = table.Column<string>(nullable: true)
16-
},
17-
constraints: table =>
18-
{
19-
table.PrimaryKey("PK_Customers", x => x.Id);
20-
});
10+
migrationBuilder.CreateTable(
11+
name: "Customers",
12+
columns: table => new
13+
{
14+
Id = table.Column<Guid>(nullable: false),
15+
Name = table.Column<string>(nullable: true)
16+
},
17+
constraints: table =>
18+
{
19+
table.PrimaryKey("PK_Customers", x => x.Id);
20+
});
2121

22-
migrationBuilder.CreateTable(
23-
name: "Items",
24-
columns: table => new
25-
{
26-
Id = table.Column<Guid>(nullable: false),
27-
Name = table.Column<string>(nullable: true),
28-
Price = table.Column<decimal>(nullable: false)
29-
},
30-
constraints: table =>
31-
{
32-
table.PrimaryKey("PK_Items", x => x.Id);
33-
});
22+
migrationBuilder.CreateTable(
23+
name: "Items",
24+
columns: table => new
25+
{
26+
Id = table.Column<Guid>(nullable: false),
27+
Name = table.Column<string>(nullable: true),
28+
Price = table.Column<decimal>(nullable: false)
29+
},
30+
constraints: table =>
31+
{
32+
table.PrimaryKey("PK_Items", x => x.Id);
33+
});
3434

35-
migrationBuilder.CreateTable(
36-
name: "Orders",
37-
columns: table => new
38-
{
39-
Id = table.Column<Guid>(nullable: false),
40-
Count = table.Column<int>(nullable: false),
41-
CustomerId = table.Column<Guid>(nullable: false),
42-
ItemId = table.Column<Guid>(nullable: false)
43-
},
44-
constraints: table =>
45-
{
46-
table.PrimaryKey("PK_Orders", x => x.Id);
47-
table.ForeignKey(
48-
name: "FK_Orders_Customers_CustomerId",
49-
column: x => x.CustomerId,
50-
principalTable: "Customers",
51-
principalColumn: "Id",
52-
onDelete: ReferentialAction.Cascade);
53-
table.ForeignKey(
54-
name: "FK_Orders_Items_ItemId",
55-
column: x => x.ItemId,
56-
principalTable: "Items",
57-
principalColumn: "Id",
58-
onDelete: ReferentialAction.Cascade);
59-
});
35+
migrationBuilder.CreateTable(
36+
name: "Orders",
37+
columns: table => new
38+
{
39+
Id = table.Column<Guid>(nullable: false),
40+
Count = table.Column<int>(nullable: false),
41+
CustomerId = table.Column<Guid>(nullable: false),
42+
ItemId = table.Column<Guid>(nullable: false)
43+
},
44+
constraints: table =>
45+
{
46+
table.PrimaryKey("PK_Orders", x => x.Id);
47+
table.ForeignKey(
48+
name: "FK_Orders_Customers_CustomerId",
49+
column: x => x.CustomerId,
50+
principalTable: "Customers",
51+
principalColumn: "Id",
52+
onDelete: ReferentialAction.Cascade);
53+
table.ForeignKey(
54+
name: "FK_Orders_Items_ItemId",
55+
column: x => x.ItemId,
56+
principalTable: "Items",
57+
principalColumn: "Id",
58+
onDelete: ReferentialAction.Cascade);
59+
});
6060

61-
migrationBuilder.CreateIndex(
62-
name: "IX_Orders_CustomerId",
63-
table: "Orders",
64-
column: "CustomerId");
61+
migrationBuilder.CreateIndex(
62+
name: "IX_Orders_CustomerId",
63+
table: "Orders",
64+
column: "CustomerId");
6565

66-
migrationBuilder.CreateIndex(
67-
name: "IX_Orders_ItemId",
68-
table: "Orders",
69-
column: "ItemId");
70-
}
66+
migrationBuilder.CreateIndex(
67+
name: "IX_Orders_ItemId",
68+
table: "Orders",
69+
column: "ItemId");
70+
}
7171

72-
protected override void Down(MigrationBuilder migrationBuilder)
73-
{
74-
migrationBuilder.DropTable(
75-
name: "Orders");
72+
protected override void Down(MigrationBuilder migrationBuilder)
73+
{
74+
migrationBuilder.DropTable(
75+
name: "Orders");
7676

77-
migrationBuilder.DropTable(
78-
name: "Customers");
77+
migrationBuilder.DropTable(
78+
name: "Customers");
7979

80-
migrationBuilder.DropTable(
81-
name: "Items");
82-
}
80+
migrationBuilder.DropTable(
81+
name: "Items");
8382
}
8483
}

tests/EntityFrameworkCore.AutoFixture.EF3.Tests/EntityFrameworkCore.AutoFixture.EF3.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

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

16-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.27" />
17-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.27" />
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.27" />
19-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.27" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.32" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.32" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.32" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.32" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

0 commit comments

Comments
 (0)