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

External disconnected entity change tracking system to interact with EF-server #8744

Closed
weitzhandler opened this issue Jun 6, 2017 · 16 comments

Comments

@weitzhandler
Copy link
Contributor

weitzhandler commented Jun 6, 2017

Related to #5536 #4424 #8739

I'd want the entire metadata and tracking system in EF to be extracted to an external non-EF dependent assembly, so to allow change-tracking and interaction with the EF-enabled-server from a non-EF client.

There should also be a minimized graph that efficiently serializes only the necessary data, meaning for added entities: the entire entity, delete entities: the id, for modified, only modified properties along with their values.

For example

Server (get):

var query = _DbContext
  .Contacts
  .Include(c => c.Phones)
  .Include(c => c.Addresses)
  .Include(c => c.Portfolio)
    .ThenInclude(p => p.Notes);
return Ok(await query.ToTrackableGraphAsync()); //or wrap graph elsewhere afterwards
//returns proxy entities that implement an interface including graph metadata

Client:

Each entity in graph is a proxy class that implements an interface that exposes some change tracking and graph stuff or managed via a centralized EF client tool. Each entity should also have a Guid etc. that goes along the wire regardless of its DB id, so we can identify it regardless of its state.
A serializer will construct the proper IGraphChangeData for client/server, or should be a concrete.

var contacts = await efClient.GetAsync<Contact>();     

//perform changes add, delete, change in any of the graph
IGraphChangeData data = efClient.GetGraphChanges();
IGraphChangeResult result = await efClient.SaveAsync(data);
efClient.RefreshGraph(contacts, result);

Server (put):

_DbContext.AttachGraph(IGraphChangeData data);
try { 
  var result = await _DbContext.SaveChangesAsync();
  return Ok(result);

This is so compelling.

@ErikEJ
Copy link
Contributor

ErikEJ commented Jun 6, 2017

@weitzhandler http://trackableentities.github.io/ (currently not support for EF Core) ?

@weitzhandler
Copy link
Contributor Author

weitzhandler commented Jun 6, 2017

@ErikEJ
That's just that!
It looks like that project isn't maintained tho. No support for VS 2017 and this compelling project looks a bit neglected.
Would still be nice having this or a similar repo conducted by MS.

@ErikEJ
Copy link
Contributor

ErikEJ commented Jun 6, 2017

Ping @tonysneed - any comments?

@weitzhandler
Copy link
Contributor Author

weitzhandler commented Jun 6, 2017

@ErikEJ
Have you used it? Sorry for getting away from the discussion, I hope you can help:

  • Can I use Trackable Entities without its T4 templates? What do I have to include in my shared entities (server/client)
  • How do I send an entire graph to the server (for instance PUT action), what should the controller action expect?

@tonysneed
Copy link

tonysneed commented Jun 6, 2017 via email

@weitzhandler
Copy link
Contributor Author

@tonysneed wow tx for your quick answer.

  • How about the client entities? I noticed there is EntityBase and ModelBase, which of them?
  • Still unsure what the pattern of the put action accepting a graph should look like.

@tonysneed
Copy link

tonysneed commented Jun 6, 2017 via email

@weitzhandler
Copy link
Contributor Author

Thank you very much Tony!!!

Would be a great idea adding your project to .NET foundation and draw more community attention to it.

@tonysneed
Copy link

tonysneed commented Jun 7, 2017 via email

@weitzhandler
Copy link
Contributor Author

Well here's their checklist. I'm sure you've gone that far you'll go that bit more to make it into the dnf...

Should I close this issue or keep it open for the reference of for some MS ppl to see it?

And BTW, (self-quoting):

It looks like that project isn't maintained tho. No support for VS 2017 and this compelling project looks a bit neglected.

Apparently I was utterly wrong...

@tonysneed
Copy link

tonysneed commented Jun 7, 2017 via email

@ajcvickers
Copy link
Member

@tonysneed Curious what APIs you are waiting on?

@tonysneed
Copy link

@ajcvickers It's #7389 Provide access to referencing entity in TrackGraph. Looks like it's in the 2.0.0 milestone.

@ajcvickers
Copy link
Member

@tonysneed Yep, it is. I'll make sure it gets done. 😸 Would be interested to hear any other feedback you have while working on this. New APIs, confusing behaviors, etc.

@tonysneed
Copy link

@ajcvickers Thanks for working on that! I'll be sure to grab the nightlies and start playing. 😄 Happy to provide feedback on the API's!

ajcvickers added a commit that referenced this issue Jun 9, 2017
Issue #7389

Doing for preview2 due to discussion here: #8744
ajcvickers added a commit that referenced this issue Jun 9, 2017
Issue #7389

Doing for preview2 due to discussion here: #8744
ajcvickers added a commit that referenced this issue Jun 9, 2017
Issue #7389

Doing for preview2 due to discussion here: #8744
@ajcvickers
Copy link
Member

Closing as a dupe of #5536 with a comment there to look at this discussion when implementing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants