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

Equivalent events to ObjectMaterialized and SavingChanges in EF Core? #3204

Closed
user100003 opened this issue Sep 23, 2015 · 5 comments
Closed

Comments

@user100003
Copy link

Hi,

On EF6, we hook into the ObjectMaterialized and SavingChanges events very easily to perform some DateTime transformations that are required for sharing the DB with other applications.

Considering the ObjectContext API isn't there in EF7, what are the equivalent events to ObjectMaterialized and SavingChanges in order to achieve the same functionality?

// EF6.x example, db is type DbContext
ObjectContext context = ((IObjectContextAdapter)db).ObjectContext;
context.ObjectMaterialized += DateTimeReadTransform;
context.SavingChanges += DateTimeWriteTransform;

Thanks

@rowanmiller
Copy link
Contributor

This is being tracked by #626. It won't be in our November RC, but you can override SaveChanges to run your own logic before save. It should also be possible to override some low level components in DI to intercept when an object is materialized (it would be complex, but may be a way to unblock you if needed).

@user100003
Copy link
Author

@rowanmiller Thanks for the update and appreciate your suggestions. For now, we're holding off switching to EF7 (still on EF6) since the workaround suggested would be rather klunky.

#626 is good but the concern is that it's a more complex requirement, delaying the engineering, testing and final release as compared to this sub-set of requirements (just two hooks).

If not Nov-RC, are there any best guesses on when (to nearest month or quarter) this feature (perhaps in it's basic form) will be making an RC?

@rowanmiller
Copy link
Contributor

@user100003 I don't have a definite answer for you as we haven't really done any prioritization of features post the initial RTM. That said, this is a fairly fundamental requirement and so I think we'll prioritize it pretty quickly after initial release.

@marchy
Copy link

marchy commented Apr 22, 2016

+1

@TehWardy
Copy link

TehWardy commented Apr 3, 2017

same here ... looks like bot htis ticket and #626 have stopped ... is this going anywhere?
I'd like to see this in EF 6 too though if possible as performing upgrade right now would cause hell for me.

I have been using jcachat/dynamicfilters package which is sort of a good step but has some interesting problems due to the lack of "good hooks" in core EF.

Here's that other package ...

https://github.com/jcachat/EntityFramework.DynamicFilters

@divega divega changed the title Equivalent events to ObjectMaterialized and SavingChanges in EF7.x? Equivalent events to ObjectMaterialized and SavingChanges in EF Core? Feb 26, 2018
@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

5 participants