AspNetCoreLocalization
AspNetCoreLocalization copied to clipboard
Working with LocalizationModelContext
Hi again @damienbod I'm curious, how would I work with the underlying DbContext in my app? Suppose I want to seed localization data at Startup (populating the LocalizationRecords table). Or maybe I want to create a web console in my app, where I can query the records, do CRUD operations etc.
Thanks in advance :sun_with_face:
Hi @inexuscore
Seed should be possible as you have the DbContext in your project. If changes are required to the DbContext itself, then I would use the Localization.SqlLocalizer directly instead of the NuGet package and change it. We could then add this to the package if it helps others.
https://github.com/damienbod/AspNet5Localization/tree/master/AspNet5Localization/src/Localization.SqlLocalizer
Here's the context https://github.com/damienbod/AspNet5Localization/blob/master/AspNet5Localization/src/Localization.SqlLocalizer/DbStringLocalizer/LocalizationModelContext.cs
Greetings Damien
Hi @damienbod Great, I think I'll pull in the source to my project and have it as another layer. The DbContext doesn't require any changes, at least not now, not that I can think of any. But there's only one change I would make: configuring a default value for the UpdatedTimestamp column. That way we'll be able to manually add records in SSMS, Visual Studio or other clients.
Thanks for the repo!
I'll add an interface for the LocalizationModelContext : ILocalizationModelContext Then you can write your own if required, for example configuring a default value for the UpdatedTimestamp column
interface won't work, need to think of a better solution.