Add EF Core repository library targeting net8.0 alongside existing EF6 project#3
Add EF Core repository library targeting net8.0 alongside existing EF6 project#3Copilot wants to merge 3 commits into
Conversation
…ject Co-authored-by: davidbreyer <699311+davidbreyer@users.noreply.github.com>
Co-authored-by: davidbreyer <699311+davidbreyer@users.noreply.github.com>
There was a problem hiding this comment.
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.
| 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)] |
There was a problem hiding this comment.
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.
| 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; } |
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 againstMicrosoft.EntityFrameworkCore.DbContext.BaseContextdropped (EF Core usesDbContextOptions);DatabaseFactorysimplified (noDatabase.Log). Auditing not included.PersistentLayerCore— EF Core test-layer;YourCustomDataContextwired viaDbContextOptions<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
Infrastructure
NuGet.Config— added v3 source (api.nuget.org) alongside existing v2.appveyor.yml— bumped image to VS 2022; addeddotnet restoreanddotnet teststeps for Core projects.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/usr/bin/dotnet dotnet build EntityFrameworkCoreRepository/EntityFramework.Repository.Core.csproj(dns block)/usr/bin/dotnet dotnet build PersistentLayerCore/PersistentLayerCore.csproj(dns block)/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
🔒 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.