This should be really easy, I must be overlooking something. We have a couple tables related by foreign key. I'd like a single entity 'car' to pull most of its data from the car table, and to include one property, manufacturer_name, that is in the related table, 'manufacturer'. The car table includes manufacturer_id as a FK. It is permissible for a row in the car table to have null for the manufacturer_id.
I expected to go to the column mapping editor and find my property manufacturer_name and be able to assign the mapping to the manufacturer table and corresponding field. However, only those properties that have corresponding table columns show up in the editor. I added the manufacturer_name property to the car entity, but there seems to be no way to map this field.
How can I pull in this related value from the associated table?
Thanks!
Need EF entity that relates to multiple tables
First, you can add a view in your database that represents the conceptual entity and then add this view to the model, edit the entity key for it and everything will work smoothly.
You can write Defining Query to achieve this as well. This approach does not need to modify database, thus it's preferrable for some users.
If you are using Devart Entity model, you can perform all actions in design time. Just go to Model Explorer, right-click on the Model.Store node and choose the Add Defining Query... option, without XML editing.
You can write Defining Query to achieve this as well. This approach does not need to modify database, thus it's preferrable for some users.
If you are using Devart Entity model, you can perform all actions in design time. Just go to Model Explorer, right-click on the Model.Store node and choose the Add Defining Query... option, without XML editing.
Defining Query
Thanks for the response, AndreyR.
I have tried the Defining Query approach. Since our model is in edmx format I had to edit the XML myself (nice that DevArt's modeler does this for you). The WCF and Windows Service projects build and seem to run OK. My Silverlight app asks for the DefiningQuery but the service returns an empty set.
Any ideas on how to debug the entity when it is a defining query?
Thank you.
D
I have tried the Defining Query approach. Since our model is in edmx format I had to edit the XML myself (nice that DevArt's modeler does this for you). The WCF and Windows Service projects build and seem to run OK. My Silverlight app asks for the DefiningQuery but the service returns an empty set.
Any ideas on how to debug the entity when it is a defining query?
Thank you.
D