I was just wondering if there was any best practices when using Entity Framework with multi-language databases? My database design for handling this is to have a separate table for all of my translations:
[Product Table]
ProductID PK
NameId FK
DescriptionId FK
[Translation Table]
TextId PK
LanguageId
TranslationText
I am happy to go along with this approach but I was wondering if Entity Framework has any features that can help with this? It would nice to be able to have a Product entity object, give it a language and then access the name and description fields direct and in the correct language.
Thanks, Nick
As somebody has asked if I ever got a resolution for this, I thought I would add my solution to this:
I changed the DB schema so instead of having one table for all translations for different text types, I have a separate 'Text' table e.g.
[Product Table]
ProductID PK
ProductName In master language for reference
ProductDesription In master language for reference
<other product fields>
[ProductText Table]
ProductID PK
LanguageId PK
ProductName Language-Specific name
ProductDescription Language-Specific description
I have a number of these 'text' tables for local language translations for each entity type that needs it.
Then if I need to access the localised data from EF, I use the following (example is to get the German text):
Product product = db.Products.Where(m => m.ProductId == 1);
ProductName germanProductName = product.ProductNames(m => m.LanguageId == "de");
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With