Migration creates Implicit relational tables in database for an explicit M-N relationship
I have created two models, Parameters and Tests. Also, there is a model that defines explicit M-N relationship between these models.
When I migrate the schema to database, it is also creating a table "_ParameterToTest" in the database, that is usually created for implicit relationship. How do I avoid creating this database?
When I migrate the schema to database, it is also creating a table "_ParameterToTest" in the database, that is usually created for implicit relationship. How do I avoid creating this database?
Solution
Hi @Faiz Khatri
In your schema, you have defined an explicit many-to-many relationship using the
To avoid creating the additional
Something like this should work
In your schema, you have defined an explicit many-to-many relationship using the
ParametersToTests model. However, you've also defined an implicit many-to-many relationship by including Parameters Parameter[] in the Test model and Tests Test[] in the Parameter model.To avoid creating the additional
_ParameterToTest table, you need to remove these implicit relation fields and rely solely on your explicit relationship through the ParametersToTests model. Something like this should work