locked
Extending Entity Framework model RRS feed

  • Question

  • Hi!

    I'm a noob to the EntityFramework and checking out features for our development to change the current database access with EntityFramework and Linq to Entities capabilities.

    Now I'm confronting a last "KO" criteria:

    I have the following situation:
    - We are creating a plattform solution with a default database schema. For this I created a ssdl, csdl and msl file. Additionally I generated the Entities.cs class out of the csdl file. I can now access the data with EF and Linq to Entities - all is fine
    - In case of a specific plattform implementation (customer specific solution) we sometimes need to extend the data in the following way:

    * Guess we have a collection of classes in the plattform (described in csdl, msl and ssdl), e.g. the class PlattformA
    * In the solution we need to extend the class  PlattformA to have more fields => SolutionA extends PlattformA
    * We use the table-per-hierarchy mechanism => the table PLATTFORM_A and the table SOLUTION_A are realized in the same table in the DB, only one field more for SOLUTION_A
    Problem:
    I have access to the ssdl, msl and csdl files of the plattform. I need additional entries in the csdl, ssdl and msl file for this inheritance but I don't want to extend the plattform files. Therefore I will create three new files, each of them will extend the plattform files.
    Questions: 
    # How will I create a connection string for this set of 6 files?
    # Is this possible? I read that it is possible to use more casdl files for one ssdl and vice versa. Therefore I guess a combination must be possible too.

    For help in this I would be very grateful...

    Cheers
    Vic
    Monday, September 15, 2008 6:09 AM

Answers

  • What you have read is correct, you can use multiple CSDL files with a single SSDL file but you can not use multiple SSDL files. The solution for this does not come out of box with EF unfortunately.

    This is what I would suggest to get to a solution:

    1. Use the Using feature in CSDL to extend the Solution CSDL from Platform CSDL. I posted a small sample for Using and Extends feature at : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2304087&SiteID=1 .

    2. Use a little Xml manipulation to build SSDL and MSL files for Solution from Platform MSL.

     

     

    Thanks

    Srikanth

    Monday, September 15, 2008 7:41 AM