I am looking at how to do the following and why the entity framework doesn't let me do what I want. I Am trying to use the designer first and build my database from it using the generate database :
I want:
1) a People table, which contains name etc
2) a customer table, which contains all the data from people + customer id and other related customer properties
3) a order table linked to the customerId with order details
I have created a person entity, created a customer entity which inherits from person and created a 1 to many association between customer and an order entity.
|Person|<----|Customer|1---------*|Order|
My problem is I can't create a primary key in the customer entity to relate with orders. Am i going about this the wrong way?
Help with a design
Please try the following:Jonoh89 wrote:My problem is I can't create a primary key in the customer entity to relate with orders. Am i going about this the wrong way?
1. Create class Person with properties: ID (entity key), Name.
2. Create class Customer, then modify it:
a) add inheritance -
Base class: Person
Derived Class: Customer
Type: Table Per Type
b) add property Payment (any additional property).
3. Create class Order with properties: ID (entity key), Name. Then modify it:
a) add association
End 1 -
Class: Customer
Multiplicity: 1 (One)
Generate related property (selected)
End 2 -
Class: Order
Multiplicity: *(Many)
Generate related property (selected)
Add foreign key properties to the child class
and press OK.
b) rename just added property to CustomerID.
4. Right click on the diagram surface > Generate Database Script From Model, navigate through the wizard steps and make sure that the correct script for the database is generated.