Entity Framework

  • Thread starter Thread starter chris.kennedy
  • Start date Start date
C

chris.kennedy

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 misunderstanding how the entity framework works?
 
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! |
********************************************
 
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.
 
Fresno Bob said:
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! |
********************************************
 
Back
Top