A1VBCode Forums

DataAnnotations - Foreign Key


http://www.a1vbcode.com/vbforums/Topic32113.aspx

By luis.oliveira - 1/8/2014

I have two tables , which are called "Units " and "Products " . The primary key in the Units table called " UnidadeID ".

The Products table have two foreign keys , named " UnidadeDeCompra" and "UnidadeDeVenda" , both columns referencing the "Units" table.

In the project there are several other tables , of course , but with all the other is all right. My problem is only with the "Products" definition.



It happens that I need to create the code in the model "Entity Framework / Code First / Fluent API" using DataAnnotations in VB.Net language, but specifically for this pair of foreign keys, I have no idea how to do ... If it were a foreign key column only, or to several different tables, it would be no problem, but they are two to the same table using the cited mandatory and names that do not correspond to the field name in the referenced table... And I can not create via manager or EDMX should be through EF6, Code First.



Could anyone help me on this issue ?