Click here to Skip to main content
15,889,857 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

I am working on Entity Framework 4.1. I have created sample application in which i have three Entitees
1] Order Entity
OrderNumber
OrderDate
Status
CustomerId

2] OrderItem Entity
OrderItemNo
Quantity
Price
OrderNumber

3] Shipping Entity
ShippingId
OrderNumber
ShippingAddress
PhoneNumber


I want to create a 1:1 relationship between Order and shipping. But when i create the 1 : 1 relationship between them it gives me exception regarding ShipperId.
I am saving the order item first and then using that order number for storing the order items related to that order and then i am savin the shipping details for that respective order number.

Can u please help me how should i design my Entity Model.

Thanks,
Umesh Tayade
Posted
Comments
Ed Nutting 28-Sep-11 12:36pm    
Can you please improve your question by including the actual error message itself? Thanks, Ed :)

1 solution

First of all, don't just tell us you recieve an exception, if you do not post the exact exception then you might aswell just don't mention it at all.

That said in a 1 to 1 relation the EF expects that the two tables use the same primary key, which they also should.
So making OrderNumber the primary key in your Shepping table would resolve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900