question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-bootstrap design time provider services through Attribute

See original GitHub issue

As described in #5617, EF Core tooling currently scans the startup assembly for a class that implements IDesignTimeServices, then invokes ConfigureDesignTimeServices. This allows for registering implementations of EF Core interfaces in order to customize behavior. However, the ability to customize the EF Core toolchain could be improved, so that the requirement for the developer to add a IDesignTimeServices implementation class can be removed.

If EF tooling can scan referenced assemblies for a IDesignTimeServices implementation, then services can be configured by a class library or NuGet package rather than the developer who is consuming an extension to the EF tooling. This helps reduce the amount of friction so that the only thing a developer as to do is add a package that is self-configuring. EF tooling can scan the startup assembly first and use an IDesignTimeServices if one exists, so the developer can still control the process. But if the startup assembly does not contain an IDesignTimeServices, then EF tooling can scan referenced assemblies for an IDesignTimeServices and use it if it finds one.

In addition to bringing in IDesignTimeServices from referenced assemblies, I would suggest adding an argument to dotnet ef dbcontext scaffold for the name of a NuGet package containing an IDesignTimeServices implementation. That way, a project can reference multiple packages containing IDesignTimeServices implementations and the developer can select the one to use when executing the scaffolding command. So for example, a .NET Core library can reference a package that generates C# class as well as one that generates TypeScript classes, then he or she can pass the name of one package or the other to dotnet ef dbcontext scaffold in order to generate either C# or TypeScript classes.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
bricelamcommented, Dec 16, 2017

@tonysneed I’ve ported the EF6 pluralizer and packaged it appropriately in bricelam/EFCore.Pluralizer.

1reaction
bricelamcommented, Oct 30, 2017

My brain has been churning on this, and I think --design-time-services is too coarse-grained for what we want. It should be fine to add lots of design-time services (e.g. a pluralizer, a Migrations code generator, a Reverse Engineer code generator, etc.). The problem comes when two of those things conflict (i.e. there ends up being more than one of the same service). We mitigate this a bit by flowing in the project language (e.g. we won’t pick an F# scaffolder on a C# project), but you could still have two flavors of scaffolding for the same project language.

I wonder, however, if this problem is specific to your tool. If you added a new command (as discussed in #10156), you could replace the scaffolding factory (drafted in bricelam:lang) with one that selects based on user-input on the command line.

If it’s otherwise a problem, conflicts could be resolved by either uninstalling one package, or by adding an IDesignTimeServices implementation the the app that picks which one to use. It’s not dynamic, but I can’t see why (outside of your tool) you’d want to change it between runs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto-bootstrap design time provider services through ...
The user specifies the provider in Scaffold-DbContext , we load the assembly and look for [assembly: DesignTimeProviderServices] which points to ...
Read more >
DesignTimeProviderServicesAttri...
Identifies where to find the design time services for a given database provider. This attribute should be present in the primary assembly of...
Read more >
Entity Framework Core Extension tips & tricks - Design Time ...
Entity Framework is a powerful tool with so many features it's hard to ... Auto-bootstrap design time provider services through Attribute ...
Read more >
DesignTimeServicesReferenceAt...
Identifies where to find additional design time services. This attribute is typically used by design-time extensions. It is generally not used in ......
Read more >
Core - Prerequisites for Design-time Model Editor with ...
Problem EF Core-based XAF applications retrieve information on business classes and their properties from DbContext.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found