Skip to content

Commit

Permalink
Merge pull request #28 from TrackableEntities/ef-core-3.0-preview7
Browse files Browse the repository at this point in the history
Update to EF Core 3.0
  • Loading branch information
Anthony Sneed authored Oct 14, 2019
2 parents edc5de8 + 5139ed5 commit 12c7e18
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 28 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>TrackableEntities.Common.Core</PackageId>
<PackageVersion>1.2.0</PackageVersion>
<PackageVersion>3.0.0</PackageVersion>
<Authors>Tony Sneed</Authors>
<Company>Tony Sneed</Company>
<Title>Trackable Entities Common for .NET Standard</Title>
<Description>Assembly containing TrackingState enum and ITrackable, IMergeable interfaces.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>See: https://github.com/TrackableEntities/TrackableEntities.Core/releases/tag/v1.2.0</PackageReleaseNotes>
<PackageReleaseNotes>See: https://github.com/TrackableEntities/TrackableEntities.Core/releases/tag/v3.0.0</PackageReleaseNotes>
<PackageTags>change-tracking entity-framework-core n-tier</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/TrackableEntities/TrackableEntities.Core</PackageProjectUrl>
<PackageIconUrl>http://trackableentities.github.io/images/tracking.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<IncludeSource>true</IncludeSource>
</PropertyGroup>

Expand All @@ -28,4 +28,8 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

</Project>
Binary file added TrackableEntities.Common.Core/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions TrackableEntities.Core.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{28B18A3B-C89A-439D-AF9B-07636B9836A3}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
LICENSE = LICENSE
README.md = README.md
EndProjectSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasOne(c => c.CustomerSetting)
.WithOne(c => c.Customer);
modelBuilder.Entity<Promo>().ToTable("Promos");
modelBuilder.Entity<HolidayPromo>().ToTable("HolidayPromos");
modelBuilder.Entity<ProductInfo>()
.HasKey(pi => new { pi.ProductInfoKey1, pi.ProductInfoKey2 });
modelBuilder.Entity<Product>()
.HasOne(p => p.ProductInfo)
.WithOne(p => p.Product);
.WithOne(p => p.Product)
.HasForeignKey<ProductInfo>(pi => pi.ProductId);
modelBuilder.Entity<EmployeeTerritory>()
.HasKey(et => new { et.EmployeeId, et.TerritoryId });
}
Expand Down
5 changes: 2 additions & 3 deletions TrackableEntities.EF.Core.Tests/LoadRelatedEntitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ private void EnsureSeedData()
EnsureTestTerritory(context, TestTerritoryId3);

// Test Product Infos
EnsureTestProductInfo(context, ProductInfo1A, ProductInfo1B);
EnsureTestProductInfo(context, ProductInfo2A, ProductInfo2B);
//EnsureTestProductInfo(context, ProductInfo1A, ProductInfo1B);
//EnsureTestProductInfo(context, ProductInfo2A, ProductInfo2B);

// Save changes
context.SaveChanges();

}
private static void EnsureTestTerritory(NorthwindDbContext context, string territoryId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public partial class ProductInfo : ITrackable
{
public int ProductInfoKey1 { get; set; }
public int ProductInfoKey2 { get; set; }
public int ProductId { get; set; }
public Product Product { get; set; }

public string Info { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>

<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeFrameworkVersion>3.0.0</RuntimeFrameworkVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -15,14 +15,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 8 additions & 4 deletions TrackableEntities.EF.Core/DbContextExtensionsInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ public static class DbContextExtensionsInternal
public static void TraverseGraph(this DbContext context, object item,
Action<EntityEntryGraphNode> callback)
{
#pragma warning disable EF1001 // Internal EF Core API usage.
IStateManager stateManager = context.Entry(item).GetInfrastructure().StateManager;
var node = new EntityEntryGraphNode(stateManager.GetOrCreateEntry(item), null, null);
var node = new EntityEntryGraphNode<object>(stateManager.GetOrCreateEntry(item), null, null, null);
IEntityEntryGraphIterator graphIterator = new EntityEntryGraphIterator();
#pragma warning restore EF1001 // Internal EF Core API usage.
var visited = new HashSet<int>();

graphIterator.TraverseGraph<object>(node, null, (n, s) =>
graphIterator.TraverseGraph<object>(node, n =>
{
// Check visited
if (visited.Contains(n.Entry.Entity.GetHashCode()))
Expand All @@ -54,12 +56,14 @@ public static void TraverseGraph(this DbContext context, object item,
public static async Task TraverseGraphAsync(this DbContext context, object item,
Func<EntityEntryGraphNode, Task> callback)
{
#pragma warning disable EF1001 // Internal EF Core API usage.
IStateManager stateManager = context.Entry(item).GetInfrastructure().StateManager;
var node = new EntityEntryGraphNode(stateManager.GetOrCreateEntry(item), null, null);
var node = new EntityEntryGraphNode<object>(stateManager.GetOrCreateEntry(item), null, null, null);
IEntityEntryGraphIterator graphIterator = new EntityEntryGraphIterator();
#pragma warning restore EF1001 // Internal EF Core API usage.
var visited = new HashSet<int>();

await graphIterator.TraverseGraphAsync<object>(node, null, async (n, s, ct) =>
await graphIterator.TraverseGraphAsync<object>(node, async (n, ct) =>
{
// Check visited
if (visited.Contains(n.Entry.Entity.GetHashCode()))
Expand Down
14 changes: 9 additions & 5 deletions TrackableEntities.EF.Core/TrackableEntities.EF.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>1.2.0</PackageVersion>
<PackageVersion>3.0.0</PackageVersion>
<Authors>Tony Sneed</Authors>
<Company>Tony Sneed</Company>
<Title>Trackable Entities for EF Core</Title>
<Description>Provides an ApplyChanges extension method for DbContext that sets EntityState on trackable entities, so they can be saved by a service in a single transaction.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/TrackableEntities/TrackableEntities.Core</PackageProjectUrl>
<PackageIconUrl>http://trackableentities.github.io/images/tracking.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>change-tracking entity-framework-core n-tier</PackageTags>
<PackageReleaseNotes>See: https://github.com/TrackableEntities/TrackableEntities.Core/releases/tag/v1.2.0</PackageReleaseNotes>
<PackageReleaseNotes>See: https://github.com/TrackableEntities/TrackableEntities.Core/releases/tag/v3.0.0</PackageReleaseNotes>
<IncludeSource>true</IncludeSource>
</PropertyGroup>

Expand All @@ -27,7 +27,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.1" />
<None Include="icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file added TrackableEntities.EF.Core/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.0.100"
}
}

0 comments on commit 12c7e18

Please sign in to comment.