views:

110

answers:

1

1 - Is it necessary to have foreign key to obtain a Relation in Entity Framework between each entity.?
2 - I have a Language Table and many many table with a foreign key related to the language table. Is it right to add this foreign key or I should do something else ?

Ex:
Language
LangID
LangName

TableTextA
TblAID
TextInfo
LangID

TableTextB
TblBID
TextInfo
LangID

TableTextC
TblCID
TextInfo
LangID
etc ...


Thanks

+1  A: 

You can always get the Language info by using the Linq queries like:

YourContainer db = new YourContainer();

var Text = from m in db.TableTextASet
           join n in db.LanguageSet on n.LangID equals m.LangID
           select new
           {
               Id = m.TblAID,
               Text = m.TextInfo,
               Language = n.LangName
           };

So setting the association is not really necessary. However I strongly recommend you to do so.

Rodrigo Waltenberg