locked
Can I just use classes instead of .edmx? RRS feed

  • Question

  • User-618475340 posted

    All I'm trying to achieve is creating these two many-to-many relationships that happen to share a table.

    AspNetUsers.1-----* BandAssigns*-----1.Bands
    AspNetUsers.1-----*VenueAssigns*-----1.Venues

    How can I do this in EF? I tried two separate .edmx but it won't let me use AspNetUsers in both models.   I considered putting all 5 tables in one entity data model, but then the Bands and Venues tables are in yet other relationships also.  This would have been straightforward in WebForms.  How do I get round this? Links to videos and tutorials would be very helpful.

    Wednesday, May 20, 2015 8:55 AM

Answers

  • User-1454326058 posted

    Hi bigyeti,

    I tried two separate .edmx but it won't let me use AspNetUsers in both models.   I considered putting all 5 tables in one entity data model, but then the Bands and Venues tables are in yet other relationships also.

    Please provide the detail steps that you do.

    What do you mean it won’t let me use AspNetUsers in both models?

    On the other hand, you could configure many to many relationships through code first mode.

    # Configure Many-to-Many relationship using Code First Approach

    http://www.entityframeworktutorial.net/code-first/configure-many-to-many-relationship-in-code-first.aspx

    Regards

    Starain

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 21, 2015 2:18 AM

All replies

  • User-474980206 posted

    EF is no different in webforms, nor is required for MVC. While EF is common in MVC its a separate technology (in because MVC is stateless, many of the features don't work as EF is statefull, but stateless support as improved). You should start here:

        https://msdn.microsoft.com/en-us/data/ee712907

    EF is moving its forum support to stackoverflow.

     

    Wednesday, May 20, 2015 10:52 AM
  • User-1454326058 posted

    Hi bigyeti,

    I tried two separate .edmx but it won't let me use AspNetUsers in both models.   I considered putting all 5 tables in one entity data model, but then the Bands and Venues tables are in yet other relationships also.

    Please provide the detail steps that you do.

    What do you mean it won’t let me use AspNetUsers in both models?

    On the other hand, you could configure many to many relationships through code first mode.

    # Configure Many-to-Many relationship using Code First Approach

    http://www.entityframeworktutorial.net/code-first/configure-many-to-many-relationship-in-code-first.aspx

    Regards

    Starain

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 21, 2015 2:18 AM
  • User-618475340 posted
    I recreated it as a single class rather than the edmx route and it works fine now.
    Thursday, May 21, 2015 3:54 AM