Use of Entity Framework Core not viable while pulling from database

Post author
Omar Salas

What do you recommend for using ef core, now for saving the process is the same but it is not feasible make the lot of include, theinclude to load an EDI Message, if using LazyLoading the n+1 issue raise.

Comments

6 comments

  • Comment author
    Admin

    We have only tested the templates with Entity Framework 6. I can recommend you to refer to MSDN's documentation on how to work with EF Core. The EDI templates are simple C# classes; hence, all Microsoft recommendations will also apply to the EDI templates.

    0
  • Comment author
    Omar Salas

    Hi Don. I know EDI Templates are just POCOs, the main issue is that with EF vs EF Core you just need to Load the root entity and the complete EDI Template is populated from Database, in the case of EF Core a lot of Include, ThenInclude need to be writte, maybe a Helper that abstract this work can be include in the Library o Examples.

     

    Regards

    0
  • Comment author
    Admin

    Hi,

    We are not actively looking into this because it's Entity Framework's thing. EdiFabric's templates CAN be used with Entity Framework 6, but that's about the extent we have the resources to go to. This doesn't mean that we won't consider creating some kind of helper, as you said, at some point in the future.

    0
  • Comment author
    Omar Salas

    Hi Don. Here i try to use the template with EF Core. The saving process was a success, but the pulling process doesn't work neither with Eager loading nor Lazy Loading, the only property is loaded is Id property. Do you have any recommendation.

    var res = db.TS837P.Include(x => x.ST)
    .Include(x => x.BHT_BeginningOfHierarchicalTransaction)
    .Include(x => x.AllNM1)
    .ThenInclude(x => x.Loop1000A).ThenInclude(x => x.NM1_SubmitterName).FirstOrDefault();

    0
  • Comment author
    Dariana Contreras

    Hi, Omar.. How did  you do saving process using EF Core? I'm having issues with it, because the saved data is always NULL.

    0
  • Comment author
    Admin

    Hi Omar,

    Please follow the instructions in the Entity Framework Core Specifics and How to migrate the DB context paragraphs to modify the templates (link here). We also released the Entity Framework Core templates for HIPAA 5010; here is an example for 837P.

    The query uses lazy loading, which you correctly pointed that can result in the N+1 issue, so you are free to modify the retrieval logic. All navigation properties in the templates are Single, e.g., one way, from parent to child, so there is no circular retrieval of unnecessary data. For generating the full EDI message, you will need to query ALL related tables, so lazy loading is the only viable way to reconstruct the whole message that was saved.

    0

Please sign in to leave a comment.