Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Compile time model generation. #3610

Closed
Antaris opened this issue Oct 30, 2015 · 1 comment
Closed

Proposal: Compile time model generation. #3610

Antaris opened this issue Oct 30, 2015 · 1 comment

Comments

@Antaris
Copy link

Antaris commented Oct 30, 2015

With the ICompileModule feature provided by the DNX, would it be possible to provide the ability to create a compile time instance of Model where the properties of the model are statically added through compile-time code generation?

E.g. using a PreCompileDatabaseModelCompileModule (ala Razor's pre-compilation compile model), that takes the target compilation, finds an non-abstract DbContext derivatives (potentially with a [PreCompile] opt-in attribute), and generate a class at runtime, something like:

    public class Model<TContext> : IModel, IModel<TContext> { }

Would it then be possible for EF to scan for instances of IModel<TContext>, create the instance and inject through DbContextOptions.UseModel(model)?

I'm just wondering that as the database model is immutable once the DB context is created, is their a benefit of offloading the model builder and verification tasks to compile time instead of runtime?

Probably no small task, and probably more for chasing absolute start-up performance and efficiencies.

@rowanmiller
Copy link
Contributor

This feature is already tracked by #1906. We prototyped this early on but it has not been turned into a stable feature yet.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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

No branches or pull requests

3 participants