Entity Framework Basics and Multi-Language Databases

I'm just wondering if there were any recommendations when using Entity Framework with multilingual databases? My database project for handling this is to have a separate table for all my translations:

[Product Table] ProductID PK NameId FK DescriptionId FK [Translation Table] TextId PK LanguageId TranslationText 

I am happy to agree with this approach, but I was wondering if the Entity Framework has any features that can help with this? It would be nice to have a Product object object, give it a language, and then access the name and description fields directly and in the correct language.

Thanks Nick

+7
entity-framework multilanguage multilingual
source share
2 answers

As someone asked if I have permission for this, I thought I'd add my solution:

I changed the database schema, so instead of a single table for all translations for different types of text, I have a separate table called β€œText”, for example.

 [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 translation into the local language for each type of entity that it needs.

Then, if I need to access localized data from EF, I use the following (for example, to get German text):

 Product product = db.Products.Where(m => m.ProductId == 1); ProductName germanProductName = product.ProductNames(m => m.LanguageId == "de"); 

Hope this helps

+2
source share

Entity Framework is a general-purpose ORM, it does not offer any domain-specific functions. Application-specific multilingual support is a domain-specific issue.

Are you looking for something specific?

+1
source share

All Articles