I have many tables that have TextID column which refers to the translation table. Translation table needs also LanguageID to get translated text in desired language. My problem is that I do not have LanguageID in my database, it is predefined in the system and I do not know how can I define it using Fluent API, i.e this can be my model:
public partial class MyEntity
{
public short ID { get; set; }
public Nullable<int> TextID { get; set; }
[NotMapped]
public Nullable<int> LanguageID { get; set; }
public virtual TEXT_TRANSLATION Translation { get; set; }
}
And the translation table:
public partial class TEXT_TRANSLATION
{
[Key, Column(Order = 0)]
public int TextID { get; set; }
[Key, Column(Order = 1)]
public int LanguageID { get; set; }
public string TranslatedText { get; set; }
}
Basically I need navigation like this:
myEntity.Translation.TranslatedText
While using SQL, I would do it like this:
Left Join TEXT_TRANSLATION ON
MyEntity.TextID = TEXT_TRANSLATION.TextID
AND TEXT_TRANSLATION.LanguageID = 1033
Basically I want to use TextID foreign key and get ONLY ONE translation - LanguageID is static and predefined in context.
I can't change existing DB schema. It would be perfect if I won't need to map LanguageID field in my code, just use it inside mapping like a system parameter. Is it even possible with EF?