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:
LangID
LangName
TblAID
TextInfo
LangID
TblBID
TextInfo
LangID
TblCID
TextInfo
LangID
etc ...
Thanks
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.