How to relate a SQL based entity with an Object based entity in Entity Framework

Discussion in 'ASP .Net' started by markla, Oct 3, 2008.

  1. markla

    markla Guest

    Hi,

    I have an Entity data model built in Entity Framework, which sources data
    primarily from an MS SQL 2008 database, and sources some static (data
    dictionary) values from code-based objects. I know I *could* store the data
    dict values in SQL: for various reasons that's not the path I want to take.

    I have some lookups, which are based on code-based Objects. They are
    encapsulated in Objects because the values can change during processing, and
    are not persisted to the database, and they derive from "EntityObject" so
    they are EF-ready.

    For example, I may have an EF object "Event", and an Object type
    "EventType". Event is stored in the database, however EventType is loaded
    depending on what types I support in an application variant (depending on
    DLLs loaded).

    In looking at the edmx file and other info, I can't see how to mix SQL and
    Non-SQL Object based entities.

    How can I create an EF relation between the SQL based "Event", and an Object
    based "EventType"?

    Thanks in advance for assistance,
    +Mark
     
    markla, Oct 3, 2008
    #1
    1. Advertising

  2. markla

    Steven Cheng Guest

    Hi Markla,

    As for "mixing the SQL and Non-SQL. object entities", here are some of my
    understanding and suggestion.

    The ADO.NET entity framework and EDM mainly focus on the object mapping
    between code level and backend database source. So generally, the current
    tool and IDE support will focus on generating the database to class
    mapping. For your scenario that you want to extend the entities so as to
    support some class/objects mapping to non-database source, I think you can
    just add a partial class code file to extend the generated entity
    classes(from database). For example, if you want the main "xxxxxEntity"
    class contains some methods which query a file or calcuate via algorithm on
    the fly, you can add a custom method for the class in that partial class
    file.

    #Customizing Objects (Entity Framework)
    http://msdn.microsoft.com/en-us/library/bb738612.aspx

    If you want to add not only custom functionality(methods), but also classes
    that do not directly mapping to any database table, I'm afraid you need to
    maintain those classes yourself in different source code file. However ,I
    think it is still quite convenient for you to use them together via LINQ
    (linq to entity + linq to objects).

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: "markla" <>
    >Subject: How to relate a SQL based entity with an Object based entity in

    Entity Framework
    >Date: Fri, 3 Oct 2008 22:37:35 +1000
    >
    >Hi,
    >
    >I have an Entity data model built in Entity Framework, which sources data
    >primarily from an MS SQL 2008 database, and sources some static (data
    >dictionary) values from code-based objects. I know I *could* store the

    data
    >dict values in SQL: for various reasons that's not the path I want to take.
    >
    >I have some lookups, which are based on code-based Objects. They are
    >encapsulated in Objects because the values can change during processing,

    and
    >are not persisted to the database, and they derive from "EntityObject" so
    >they are EF-ready.
    >
    >For example, I may have an EF object "Event", and an Object type
    >"EventType". Event is stored in the database, however EventType is loaded
    >depending on what types I support in an application variant (depending on
    >DLLs loaded).
    >
    >In looking at the edmx file and other info, I can't see how to mix SQL and
    >Non-SQL Object based entities.
    >
    >How can I create an EF relation between the SQL based "Event", and an

    Object
    >based "EventType"?
    >
    >Thanks in advance for assistance,
    >+Mark
    >
    >
     
    Steven Cheng, Oct 6, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    1
    Views:
    2,741
    Teemu Keiski
    Apr 8, 2006
  2. Jerry
    Replies:
    10
    Views:
    513
  3. Li Daobing
    Replies:
    1
    Views:
    398
    Tom Widmer
    Jun 21, 2006
  4. Ben Daniel
    Replies:
    4
    Views:
    2,770
    Ben Daniel
    Oct 14, 2007
  5. Navin
    Replies:
    1
    Views:
    705
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page