Skip to content

Add EF Core repository library targeting net8.0 alongside existing EF6 project#3

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/upgrade-dotnet-core-entity-framework
Draft

Add EF Core repository library targeting net8.0 alongside existing EF6 project#3
Copilot wants to merge 3 commits into
masterfrom
copilot/upgrade-dotnet-core-entity-framework

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 22, 2026

The existing repository library targets .NET 4.5 / EF6 only. This adds a parallel EF Core implementation for .NET Core applications while leaving the EF6 projects untouched.

New Projects

  • EntityFrameworkCoreRepository (net8.0) — Core library; BaseRepository<C,T>, DatabaseFactory<C>, Delta<T>, and all interfaces re-declared against Microsoft.EntityFrameworkCore.DbContext. BaseContext dropped (EF Core uses DbContextOptions); DatabaseFactory simplified (no Database.Log). Auditing not included.
  • PersistentLayerCore — EF Core test-layer; YourCustomDataContext wired via DbContextOptions<T> with fluent composite-key config.
  • EntityFrameworkCoreRepositoryTests — 23 MSTest tests (read, create, update, delete, Delta, async, composite keys, ignore-fields) using EF Core InMemory in place of Effort.EF6.

Usage

// Context uses DbContextOptions instead of EF6 BaseContext
public class AppDbContext : DbContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
    public DbSet<Order> Orders { get; set; }
}

// Repository unchanged pattern from EF6
public class OrderRepository : BaseRepository<AppDbContext, Order>, IOrderRepository
{
    public OrderRepository(IDatabaseFactory<AppDbContext> factory) : base(factory.GetNewDbContext()) { }
}

Infrastructure

  • NuGet.Config — added v3 source (api.nuget.org) alongside existing v2.
  • appveyor.yml — bumped image to VS 2022; added dotnet restore and dotnet test steps for Core projects.
  • All three projects added to EntityFrameworkRepository6.sln.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.nuget.org
    • Triggering command: /usr/bin/dotnet dotnet build EntityFrameworkCoreRepository/EntityFramework.Repository.Core.csproj (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build PersistentLayerCore/PersistentLayerCore.csproj (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build EntityFrameworkCoreRepositoryTests/EntityFramework.Repository.Core.Tests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

I need to upgrade this project for .NET Core and the latest entity framework. I realize it might need to lose some features, like auditing. It would also be great if the core version could exist in a separate project so this could still be used for older applications.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 22, 2026 19:55
…ject

Co-authored-by: davidbreyer <699311+davidbreyer@users.noreply.github.com>
Co-authored-by: davidbreyer <699311+davidbreyer@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade project for .NET Core and latest Entity Framework Add EF Core repository library targeting net8.0 alongside existing EF6 project Feb 22, 2026
Copilot AI requested a review from davidbreyer February 22, 2026 19:57
@davidbreyer davidbreyer requested review from Copilot and removed request for davidbreyer February 22, 2026 22:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a parallel EF Core implementation targeting .NET 8.0 alongside the existing Entity Framework 6 library, enabling the repository pattern to be used in modern .NET Core applications while preserving backward compatibility for existing .NET Framework applications.

Changes:

  • Added three new projects: EntityFrameworkCoreRepository (core library), PersistentLayerCore (test support layer), and EntityFrameworkCoreRepositoryTests (test suite with 23 MSTest tests)
  • Updated build infrastructure: upgraded AppVeyor to VS 2022, added NuGet v3 API endpoint, configured .NET Core restore and test steps
  • Implemented EF Core versions of BaseRepository, DatabaseFactory, Delta, and all interface definitions with nullable reference type support

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
appveyor.yml Updated to VS 2022 image and added dotnet restore/test commands for EF Core projects
NuGet.Config Added NuGet v3 API endpoint alongside existing v2 source
.gitignore Added .nuget directory to ignore list
EntityFrameworkRepository6.sln Added three new EF Core projects with solution folders and x64/x86 platform configurations
EntityFrameworkCoreRepository/BaseRepository.cs Core repository implementation adapted for EF Core with nullable reference types and improved exception handling
EntityFrameworkCoreRepository/DatabaseFactory.cs Simplified database factory without EF6's Database.Log property
EntityFrameworkCoreRepository/Delta.cs Delta pattern implementation with improved exception handling (removed stack-trace-losing throw)
EntityFrameworkCoreRepository/Interfaces/*.cs Interface definitions matching EF6 API but adapted for EF Core DbContext
EntityFrameworkCoreRepository/EntityFramework.Repository.Core.csproj Project targeting net8.0 with EF Core 8.0.0 reference
PersistentLayerCore/Contexts/YourCustomDataContext.cs Test context using DbContextOptions pattern with Fluent API composite key configuration
PersistentLayerCore/Entities/*.cs Test entity definitions with nullable reference types enabled
PersistentLayerCore/Repositories/*.cs Sample repository implementations demonstrating the repository pattern
PersistentLayerCore/PersistentLayerCore.csproj Test support layer project with EF Core and InMemory provider references
EntityFrameworkCoreRepositoryTests/SampleData/TestExampleDatabaseFactory.cs Test database factory using EF Core InMemory provider with proper test data seeding (7 entities)
EntityFrameworkCoreRepositoryTests/*Tests.cs Comprehensive test suite covering CRUD operations, Delta updates, composite keys, and async methods
EntityFrameworkCoreRepositoryTests/EntityFramework.Repository.Core.Tests.csproj MSTest project configuration with EF Core InMemory provider

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +12
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PersistentLayerCore.Entities
{
public class SimpleCompositeKeyEntity
{
[Key]
[Column(Order = 1)]
public int Id { get; set; }
[Key]
[Column(Order = 2)]
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The composite key annotations using multiple [Key] attributes and [Column(Order = n)] are not the recommended approach in EF Core. While they may still work in some cases, EF Core has deprecated this pattern in favor of the Fluent API configuration. Since the composite key is already correctly configured in YourCustomDataContext.OnModelCreating using modelBuilder.Entity().HasKey(e => new { e.Id, e.Name }), these data annotations are redundant and potentially misleading. Consider removing these attributes and relying solely on the Fluent API configuration for clarity and consistency with EF Core best practices.

Suggested change
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PersistentLayerCore.Entities
{
public class SimpleCompositeKeyEntity
{
[Key]
[Column(Order = 1)]
public int Id { get; set; }
[Key]
[Column(Order = 2)]
namespace PersistentLayerCore.Entities
{
public class SimpleCompositeKeyEntity
{
public int Id { get; set; }

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants