Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 26, 2025

Fixes #3390 and #4013

The design-time services documentation was outdated and contained broken code samples that don't work with EF Core 6.0+. This PR updates the documentation to reflect the current state of the design-time services API.

Issues Fixed

CustomTools.cs sample broken in .NET 6.0+ (#4013)

The main issue was that serviceProvider.GetService<IMigrationsScaffolder>() returns null in EF Core 6.0+ because the service registration pattern had changed. The sample now uses:

// Create design-time services
var serviceCollection = new ServiceCollection();

// Add the core design-time services
serviceCollection.AddEntityFrameworkDesignTimeServices();

// Add services from the DbContext
serviceCollection.AddDbContextDesignTimeServices(db);

var serviceProvider = serviceCollection.BuildServiceProvider();

// Use GetRequiredService instead of GetService for better error handling
var migrationsScaffolder = serviceProvider.GetRequiredService<IMigrationsScaffolder>();

Outdated service list (#3390)

The documentation listed only 10 design-time services when there are now 23+ services available. Added all current services including:

  • ICandidateNamingService - Generates candidate names for entities and properties
  • ICSharpMigrationOperationGenerator - Generates C# code for migration operations
  • ICompiledModelCodeGenerator - Generates code for compiled model metadata
  • IPrecompiledQueryCodeGenerator - Generates code for precompiled queries
  • And many others

Additional Improvements

  • Updated PackageReference example from version 3.1.9 to 8.0.0
  • Added advanced customization example showing how to override CSharpHelper.ShouldUseFullName
  • Added explanatory note about the streamlined service registration in EF Core 6.0+
  • Fixed grammar in tools.md ("paths" instead of "path")
  • Validated changes by creating and building a test project to ensure the sample code works

The updated documentation now accurately reflects the current EF Core design-time services API and provides working examples for developers.

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:

  • https://github.com/api/repos/dotnet/efcore/issues/23595
    • Triggering command: curl -s REDACTED (http block)

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

Original prompt

Fix @dotnet/EntityFramework.Docs/issues/3390 and @dotnet/EntityFramework.Docs/issues/4013 by updating the documentation for design services. Read all the comments to make sure you have enough context. Also, examine the implementation of @dotnet/efcore/files/src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title Fix @dotnet/EntityFramework.Docs/issues/3390 and @dotnet/EntityFramework.Docs/issues/4013 by updating the documentation for design services. Read all the comments to make sure you have enough context. Also, examine the implementation of @dotnet/efcore/... Fix design-time services documentation for EF Core 6.0+ Sep 26, 2025
@Copilot Copilot AI requested a review from AndriySvyryd September 26, 2025 20:32
Copilot finished work on behalf of AndriySvyryd September 26, 2025 20:32
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.

Update Design-time services
2 participants