8

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

Nick Reeve
  • 1,658
  • 2
  • 22
  • 32

2 Answers2

3

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
  • 1,658
  • 2
  • 22
  • 32
1

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
  • 34,502
  • 9
  • 78
  • 118
  • 2
    Not looking for anything specific no. Was just wondering if there was any best practices when doing multi-lingual solutions with EF – Nick Reeve May 21 '10 at 12:39