sql server - Table foreign key / association to itself? -


I have a table that stores a list of stores that looks like this

  InventoryIID Ent ParentID Short Shadow CAC ... [Other Product Data] ...  

In the table will be present with the PainterID of a T-shirt-1. In the parent ID field, the original parent There will be a difference of size and color in the same table with the inventory ID.

Easy

  inventory ID | ParentID | ShortDesc ----- -------------------------------------------- --- 111 -1 Skull T-shirt 112 111 Skull T-shirt Black Small 113 111 Skull T-Shirt Black Medium 114 111 Scalp T Shirt Black Large 115 111 Skull T-Shirt White Small It is possible that I can use a foreign key or association where I use this DB with the Entity Framework, I can get a navigation property on this unit, which is the inventory of all the inventory institutions. Will the list be?   

Yes, it works just fine. For a real-world example, create a model of the Northwind database with the default settings, and see the employee supervisor relationship. The unit framework will not automatically get the name of the supervisor property right, but the association itself works, and you can manually change the name of the property.

About your specific example, let me know -1 . If this real list is the actual primary key of the record, then it is okay. If a magic does not show any records, either use the tap or make it a real record. To get the unit framework to recognize this relationship, you will need to create a real foreign foreign key, so all the values ​​must actually be referenced to the records.


Comments