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

dynamic columns configuration using EF #7252

Closed
qianthinkover opened this issue Dec 15, 2016 · 2 comments
Closed

dynamic columns configuration using EF #7252

qianthinkover opened this issue Dec 15, 2016 · 2 comments
Labels
closed-no-further-action The issue is closed and no further action is planned.

Comments

@qianthinkover
Copy link

qianthinkover commented Dec 15, 2016

When use code-first to develop ORM program,that will make static template for this db model,
if db table changes,the code-model will change either,so if there is one way to implement this dynamic columns mapping at run-time configuration ?

@divega
Copy link
Contributor

divega commented Jan 21, 2017

@qianthinkover there are several features that could make working with dynamic models easier that are covered in this issue in the backlog: #2282.

Within the current feature set, there is at least one thing that could help you easily make programmatic changes to the model, but it is limited to adding properties to the EF model without modifying the .NET classes: the ability to defined "shadow state" properties:

// OnModelCreating:
modelBuilder.Entity<Item>().Property<int>("Rating");

// Usage:
var item = context.Item.First(condition);
var rating = context.Entry(item).Property<int>("Rating").CurrentValue;

We also have a rich metadata API that is lower level than the fluent API used in code first and which can be used to mutate the model in several ways.

If the "source of truth" of your model is the database schema and you only need to make changes occasionally, you may be better of re-scaffolding the model.

Hope this helps.

@divega divega closed this as completed Jan 21, 2017
@divega divega added the closed-no-further-action The issue is closed and no further action is planned. label Jan 21, 2017
@qianthinkover
Copy link
Author

Yeah thanks for helping, Hope more features will achieved in future,

@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
closed-no-further-action The issue is closed and no further action is planned.
Projects
None yet
Development

No branches or pull requests

3 participants