473,549 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Entity Framework

I am really struggling to create an entity which maps to 2 "base"
entities. I have a customer and invoice entity which are based in
tables in a one to many relationship. I have tried:

1. Creating a Invoice Entity based on the Invoice and adding a mapping
to both tables: I can't validate the model it says "Two entities with
different keys are mapped to the same row. Ensure these two mapping
fragments do not map two groups of entities with overlapping keys to
the same group of rows." When I add mappings to tables there is no way
to map to the primary key of invoices but when I validate it says
"Problem in Mapping Fragment starting at line 102: Must specify
mapping for all key properties "

Basically I want to create an entity something similar to a view. I am
I misunderstandin g how the entity framework works?
Sep 15 '08 #1
3 1971
Entity Framework is designed to create objects out of data. If you use the
standard drag and drop model, you can drag the two tables and you will then
have a parent object and 0 to n child objects.

If you want to use it like a view, you are better to connect to stored
procedure(s) or a view for your entity, depending on what you are doing with
the data in your application.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************
<ch***********@ peninsula-uk.comwrote in message
news:2e******** *************** ***********@m45 g2000hsb.google groups.com...
>I am really struggling to create an entity which maps to 2 "base"
entities. I have a customer and invoice entity which are based in
tables in a one to many relationship. I have tried:

1. Creating a Invoice Entity based on the Invoice and adding a mapping
to both tables: I can't validate the model it says "Two entities with
different keys are mapped to the same row. Ensure these two mapping
fragments do not map two groups of entities with overlapping keys to
the same group of rows." When I add mappings to tables there is no way
to map to the primary key of invoices but when I validate it says
"Problem in Mapping Fragment starting at line 102: Must specify
mapping for all key properties "

Basically I want to create an entity something similar to a view. I am
I misunderstandin g how the entity framework works?
Sep 15 '08 #2
I thought the whole point of EF was to create objects like this - so you can
map O-O things like inheritence onto your database.

"Cowboy (Gregory A. Beamer)" <No************ @comcast.netNoS pamMwrote in
message news:O1******** *****@TK2MSFTNG P06.phx.gbl...
Entity Framework is designed to create objects out of data. If you use the
standard drag and drop model, you can drag the two tables and you will
then have a parent object and 0 to n child objects.

If you want to use it like a view, you are better to connect to stored
procedure(s) or a view for your entity, depending on what you are doing
with the data in your application.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************
<ch***********@ peninsula-uk.comwrote in message
news:2e******** *************** ***********@m45 g2000hsb.google groups.com...
>>I am really struggling to create an entity which maps to 2 "base"
entities. I have a customer and invoice entity which are based in
tables in a one to many relationship. I have tried:

1. Creating a Invoice Entity based on the Invoice and adding a mapping
to both tables: I can't validate the model it says "Two entities with
different keys are mapped to the same row. Ensure these two mapping
fragments do not map two groups of entities with overlapping keys to
the same group of rows." When I add mappings to tables there is no way
to map to the primary key of invoices but when I validate it says
"Problem in Mapping Fragment starting at line 102: Must specify
mapping for all key properties "

Basically I want to create an entity something similar to a view. I am
I misunderstandin g how the entity framework works?

Sep 15 '08 #3

"Fresno Bob" <no****@nospam. comwrote in message
news:OC******** ******@TK2MSFTN GP04.phx.gbl...
>I thought the whole point of EF was to create objects like this - so you
can map O-O things like inheritence onto your database.
Ideally, yes. But in the 1.0 release, it hits the 80%, if that. I am a bit
disappointed with it, personally. I would rather use LINQ to SQL, and I have
some reservations with LINQ to SQL as a data layer.

The model currently laid out works well if you are mapping tables to objects
and keeping the basic layout. It can work with some other scenarios, but
falls a bit short when you get any complexity in your model. This is where
mapping the entities to SQL (like sprocs) works well.

I am not trying to sell you on Entity Framework. I think it works well for
the masses, but find it far too easy to step outside of the box. I wish I
could give a better story, but it is not there yet.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************

Sep 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5311
by: Erwin Gabler | last post by:
Trying to validate a document with a reference to a DTD ("PUBLIC" identifier): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE systems-description PUBLIC "-//foo/nono" ""> .... The DTD uses some kind of parameter entity with a reference to an entity file:
1
3302
by: Harold Howe | last post by:
When .NET loads an app.config at runtime (myapp.exe.config), will it honor an entity declaration? Based on what I am seeing, the answer is no, but I think, or hope, that I am doing something wrong. I tried this: // myapp.exe.config <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE configuration >
1
8301
by: Steve Wofford | last post by:
I am recieving the following. This happens when I moved it from my development system to our production SBS 2003 w/ latest .net frameworks and service packs . I developed under XPSP2 and VS2008. The error is pointing to the Web.Config of my application. System.Data.Entity was missing from the server, but was on the dev system. I tried to...
0
2658
by: Andy B | last post by:
I wanted to try out the ado.net entity framework model and see how it was different from linq to sql entities. I put a page in a web application project, added an ado.net entity model and told it to generate the model from existing database, went back to my empty page and put a GridView on it. I right clicked on the GridView and went to show...
9
2249
by: Cirene | last post by:
I'm about to begin a brand new, big, ASP.NET project (using 3.5 .net fw), VS 2008. I'm using MySQL as the backend (customer request.) I have absolutely no experience with LINQ and/or the Entity Framework. Though I am quite comfortable with ADO.NET and VB.NET. In your opinion, should I take a few days and learn it and utilize these...
5
3404
by: John | last post by:
Hi I have installed vs2008/.net3.5 SP1 (details below) but I still can't see ADO.Net Entity Framework under 'New Item' in my WinForm vb.net solution. What am I doing wrong? Thanks Regards
1
2343
by: markla | last post by:
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...
1
1958
by: Andy B | last post by:
I have to learn how to do one or the other: linq to sql or ado.net entity framework. There will be overhead no matter what way I go since I don't know either one. Which one would be the best one to use overall?
0
3441
by: zman77 | last post by:
Hi. My solution (working in VS 2008) has a C# console app, and a C# web service. The service has an entity data model. It has numerous stored procedures. For one of the stored procs, which just returns data (SELECT blah blah FROM...), I added a function import called "Iservice." I saved all, then in my console app, updated the service reference...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.