views:

169

answers:

3

Hi,

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

+2  A: 

Entity Framework is a general-purpose ORM, it doesn't offer any domain-specific features. Multilingual support for a particular application is a domain-specific problem.

Are you looking for something specific?

Dave Swersky
Not looking for anything specific no. Was just wondering if there was any best practices when doing multi-lingual solutions with EF
Nick Reeve
A: 

Did you succeed in finding best practices for your scenario? I have exactly the same question and didn't find any suggestions how this scenario should be handled also from the performance point of view

Uwe
I added an answer of what I did in the end
Nick Reeve
A: 

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

Nick Reeve

related questions