Can't get entity to work like a view

  • Thread starter Thread starter Fresno Bob
  • Start date Start date
F

Fresno Bob

Hi I'm trying to use the entity framework. I'm using a test database with 2
tables tbl_Customers who have many tbl_Invoices. What I want to create is an
entity Invoice with "look up" information tbl_Customers e.g. a property that
is part of the Invoice, which contains a customer name, much like a view.

I have tried creating an entity based on the tbl_Invoices and add table
mappings to tbl_Invoices and tbl_Customers. I get a variety of errors for
instance if I map an ID in the Invoice to the ID in the tbl_Invoices I get
an error saying there are 2 things mapping to the same id or there could be
a collision of primary keys.

I am sorry I don't have the errors to hand. Could anyone talk me through
creating an entity, which works like a view?
 
Here is a post including the errors

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?
 
Back
Top