Entity Framework Reuse Complex Class across multiple Entity Models RRS feed

  • Question

  • Hi,

    We have a scenario where we need to share the complex class between the multiple Entity Models.

    So our applicaiton contains two .edmx files one ReportsOnsite.edmx and ReportsIndia.edmx.

    We have a stored procedure which returns the data back from database to collect the data in object we have added the complex class as ReportInfo in ReportsOnsite.edmx.

    Now we need to reuse same Complex Class as ReportInfo as it is in ReportsIndia.edmx model to retrive data.

    Any Help is really appriciated. Thanks in Advance.

    • Moved by Caillen Monday, August 11, 2014 8:36 AM
    Friday, August 8, 2014 11:06 AM


  • An edmx is just a collection of public partial classes.

    If you extract this thing out into a separate class then can't you just add something inherits from that class in both edmx?

    If it has a bunch of dependencies on other things in that edmx then you have some work ahead.

    If you find that then maybe it's time to re factor and have something isn't designed to be in a data model directly.

    • Marked as answer by Fred Bao Monday, August 18, 2014 3:30 AM
    Friday, August 8, 2014 11:28 AM