jgauffin / griffin.mvccontrib

A contribution project for ASP.NET MVC3
http://blog.gauffin.org/tag/griffin-mvccontrib/
GNU Lesser General Public License v3.0
83 stars 40 forks source link

Entity Framework support for translation #36

Closed paolosanchi closed 11 years ago

paolosanchi commented 11 years ago

Hello, i use mysql a mysql database, so the "SqlServer" can't work. I've implemented the repositories for EF, so you can use any sql adapter you want. The implementation is not tested and not perfect (the import method should not work correctly), but hopefully my work could be usefull as a starting point for an improvement.

PS i didn't changed the .sln file to include the new project

PPS (configuration instructions)

By Default there should be in the web.config a connection string named "TranslationDbContext" as the DB name (by EF code first conventions), but. this should be configurated by the Database class, or we can add new contructors to TranslationDbContext.

To initialize it i use this (i use Unity for the DI): // entity framework Database.SetInitializer(new CreateDatabaseIfNotExists()); container.RegisterType<ITranslationDbContext, TranslationDbContext>(new PerThreadLifetimeManager());

// and the repositories container.RegisterType<ILocalizedTypesRepository, EFLocalizedTypesRepository>(new PerThreadLifetimeManager()); container.RegisterType<IViewLocalizationRepository, EFLocalizedViewsRepository>(new PerThreadLifetimeManager()); container.RegisterType<ITypePromptImporter, EFLocalizedTypesRepository>(new PerThreadLifetimeManager());

jgauffin commented 11 years ago

Nice done. thanks