I am migrating my php application to a .net core application using Entity Framework Core.
Several of my models have translations linked to them from the translations
table. The way the models are linked to the translations is by modelname
and modelid
. The modelname
is the name of the class and the id is the id of that object. Keep in mind, an object can have multiple translations with a unique slug.
I was wondering if it is possible to easily implement this using entity framework. So the models are linked by their id, but also filtered on their own class name. Will I have to create this relation in fluent api for every model or is there a better solution for this?
Below is a small example of how the database looks like. But in the real database, there are many more tables that have translations. The database can, of course, be modified if needed.
The solution I used to solve this is adding a new table, Translatables
. every table that is translatable now has a field translatable_id
and all translations are linked to a Translatable
.