Skip to content

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

Closed as duplicate

Description

@weitzhandler

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.

Activity

  1. weitzhandler commented on Jun 6, 2017

    @weitzhandler
    ContributorAuthor

    @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.

  2. ErikEJ commented on Jun 6, 2017

    @ErikEJ
    Contributor

    Ping @tonysneed - any comments?

  3. weitzhandler commented on Jun 6, 2017

    @weitzhandler
    ContributorAuthor

    @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?
  4. tonysneed commented on Jun 6, 2017

    @tonysneed
  5. weitzhandler commented on Jun 6, 2017

    @weitzhandler
    ContributorAuthor

    @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.
  6. tonysneed commented on Jun 6, 2017

    @tonysneed
  7. weitzhandler commented on Jun 7, 2017

    @weitzhandler
    ContributorAuthor

    Thank you very much Tony!!!

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

  8. tonysneed commented on Jun 7, 2017

    @tonysneed
  9. weitzhandler commented on Jun 7, 2017

    @weitzhandler
    ContributorAuthor

    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...

  10. tonysneed commented on Jun 7, 2017

    @tonysneed
  11. ajcvickers commented on Jun 8, 2017

    @ajcvickers
    Contributor

    @tonysneed Curious what APIs you are waiting on?

  12. tonysneed commented on Jun 8, 2017

    @tonysneed

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

  13. ajcvickers commented on Jun 8, 2017

    @ajcvickers
    Contributor

    @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.

  14. tonysneed commented on Jun 8, 2017

    @tonysneed

    @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!

  15. ajcvickers commented on Jun 12, 2017

    @ajcvickers
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions