Skip to content

Commit

Permalink
Update to net7.0 and EF7 (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: Henk Kin <[email protected]>
  • Loading branch information
HenkKin and Henk Kin authored Nov 11, 2022
1 parent f500bee commit c6785ff
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Moq.AutoMock" Version="3.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="Moq.AutoMock" Version="3.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DbContextTestBase(string testName)
.UseInMemoryDatabase(testName).EnableSensitiveDataLogging().EnableDetailedErrors()
)
);
ServiceProvider = serviceCollection.BuildServiceProvider().CreateScope().ServiceProvider;
ServiceProvider = serviceCollection.BuildServiceProvider(true).CreateScope().ServiceProvider;
UnitOfWork = ServiceProvider.GetRequiredService<IUnitOfWork>();
TestEntityRepository = ServiceProvider.GetRequiredService<IRepository<TestEntity>>();
TestEntityViewRepository = ServiceProvider.GetRequiredService<IRepository<TestEntityView>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Authors>Henk Kin</Authors>
<Description>Provides implementation for Data Access with EntityFrameworkCore.SqlServer. It provides implementation for IRepository&lt;T&gt; and DbContext. It also provides extension methods for IServiceCollection to easily adding types to .NET Core DependencyInjection. Is also supports using multiple DbContexts within same IUnitOfWork.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -13,18 +13,18 @@
<PackageReleaseNotes></PackageReleaseNotes>
<Copyright>Henk Kin</Copyright>
<PackageTags>EntityFrameworkCore, EF, SqlServer, DependencyInjection, Multiple DbContext support, DataAccess, Repository, UnitOfWork, SoftDelete, Translation, Localization, RowVersioning, Multitenancy, Filtering, Paging, Sorting, Includes</PackageTags>
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="6.0.27" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="7.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.3.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 10 additions & 10 deletions DataAccessClient.Tests/DataAccessClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
9 changes: 5 additions & 4 deletions DataAccessClient.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccessClient", "DataAccessClient\DataAccessClient.csproj", "{4446942B-C7D8-470E-919D-20F28B33499D}"
EndProject
Expand All @@ -11,14 +11,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.bettercodehub.yml = .bettercodehub.yml
appveyor.yml = appveyor.yml
..\EntityCloner.Microsoft.EntityFrameworkCore\EntityCloner.Microsoft.EntityFrameworkCore\NuGet.config = ..\EntityCloner.Microsoft.EntityFrameworkCore\EntityCloner.Microsoft.EntityFrameworkCore\NuGet.config
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccessClient.EntityFrameworkCore.SqlServer", "DataAccessClient.EntityFrameworkCore.SqlServer\DataAccessClient.EntityFrameworkCore.SqlServer.csproj", "{EDC1B0DC-1C14-4FB6-86E2-C163FF0B600F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccessClient.Tests", "DataAccessClient.Tests\DataAccessClient.Tests.csproj", "{3851FBB3-886B-42C5-B695-936920A472A8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccessClient.Tests", "DataAccessClient.Tests\DataAccessClient.Tests.csproj", "{3851FBB3-886B-42C5-B695-936920A472A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccessClient.EntityFrameworkCore.SqlServer.Tests", "DataAccessClient.EntityFrameworkCore.SqlServer.Tests\DataAccessClient.EntityFrameworkCore.SqlServer.Tests.csproj", "{B2AE5FD4-D99D-4FBD-94D0-86FEF54A9814}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccessClient.EntityFrameworkCore.SqlServer.Tests", "DataAccessClient.EntityFrameworkCore.SqlServer.Tests\DataAccessClient.EntityFrameworkCore.SqlServer.Tests.csproj", "{B2AE5FD4-D99D-4FBD-94D0-86FEF54A9814}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 3 additions & 3 deletions DataAccessClient/DataAccessClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Authors>Henk Kin</Authors>
<Company>Henk Kin</Company>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -13,14 +13,14 @@
<PackageTags>DataAccess Repository, UnitOfWork, Multitenancy, SoftDelete, RowVersioning, Filtering, Paging, Translation, Localization, Sorting, Includes</PackageTags>
<Description>Provides interfaces for Data Access with IRepository&lt;T&gt; and IUnitOfWork. Also provides haviorial interfaces for entities like IIdentifiable, ICreatable, IModifiable, ISoftDeletable, ITranslatable, ILocalizable, ITenantScopable and IRowVersioned. Last but not least provides some types for Exceptions and searching capabilities like Filtering,Paging, Sorting and Includes.</Description>
<Copyright>Henk Kin</Copyright>
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
8 changes: 5 additions & 3 deletions DataAccessClientExample/DataAccessClientExample.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.0" />

</ItemGroup>

Expand All @@ -19,6 +19,8 @@

<ItemGroup>
<Folder Include="Migrations\" />
<Folder Include="Migrations\ExampleDatabase\" />
<Folder Include="Migrations\ExampleSecondDatabase\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion DataAccessClientExample/DataLayer/Migrations.readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Installeer de dotnet ef tool (indien nodig)
- dotnet tool uninstall --global dotnet-ef

// download from https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.302-windows-x64-installer
- dotnet tool install --global dotnet-ef --add-source https://api.nuget.org/v3/index.json --ignore-failed-sources --version 5.0.5
- dotnet tool install --global dotnet-ef --add-source https://api.nuget.org/v3/index.json --ignore-failed-sources --version 7.0.0


dotnet ef migrations Add Initial --context ExampleDbContext --output-dir Migrations/ExampleDatabase
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

namespace DataAccessClientExample.Migrations.ExampleDatabase
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
Expand Down Expand Up @@ -51,6 +53,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("DataAccessClientExample.DataLayer.ExampleEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

b.Property<int>("CreatedById")
.HasColumnType("int");
Expand Down Expand Up @@ -98,6 +98,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");

b.ToTable((string)null);

b.ToSqlQuery("SELECT e.Id, et.LocaleId, e.Name, et.Description FROM dbo.ExampleEntities e INNER JOIN dbo.ExampleEntityTranslation et ON e.Id = et.TranslatedEntityId");
});

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

namespace DataAccessClientExample.Migrations.ExampleSecondDatabase
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
Expand Down Expand Up @@ -74,6 +76,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
Expand Down
Loading

0 comments on commit c6785ff

Please sign in to comment.