By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,972 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,972 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Oct 3 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#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/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "markla" <ma****@noemail.noemail>
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

Oct 6 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.