Dynamic association with variable entity/table RRS feed

  • Question



    I am working on adding an EDM onto an existing SQL Server schema.


    Several tables have a relationship structure where instead of a foreign key, the reference consists of two columns:

       -  column specifying the target table

       -  column specifying the unique key value in the target table


    I cannot think of a way of modelling this type of relationship in Entity Framework and I wonder if it is possible to model such an relationship explicitly ?





    Tuesday, September 23, 2008 1:53 PM


  • EF does not directly support dynamic mapping like you described. You could probably try 2 EF features to experiment with: defining query and stored procedure updating.


    In SSDL you can define a new table (not a real table in DB) with a defining query. In that native query you can write whatever you want to fetch the data. In your case, try define a table this way that would be mapped to the association set.


    And if you want updates, you need to write stored procedures for it because table defined using defining query cannot be updated directly. HTH.



    Friday, September 26, 2008 10:31 PM