This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, Please bear with me as we just started using Lightspeed. I am creating an example program with 3 entities - User, Permission and an entity for the ThoughAssociation, UserPermission. I have split these into 3 separate models, as show below They all share the same name, and both Permissions and UserPermission has the 'Is Linked Child' set to true. I then create the migrations (in order to create the initial schema from code) and then I created a console app in the same solution to run the migrations, I ran the migrations using the following code, and they are in the order in which I created the migrations.
However, when I run the application I get the following exception: Npgsql.NpgsqlException was unhandled , HResult=-214746725, Message=ERROR: 42P01: relation "userpermissions" does not exist I tried to change the order in which I am doing the migrations by doing the userpermissions migration first, but that just results in another exception for the "users" relation. By the looks of it, I cannot create any of these 3 tables because they depend on the existence of each other. What is the proper way of doing this? Thank you. |
|
|
Is there a particular reason you have split your migrations across 3 assemblies given they are linked? Similarly why is the model split into 3 parts? Your migrations will need to be contained within a single assembly.
|
|
|
Hi Jeremy, Thanks for the reply. The reason why the models are split is because we are going to have lots and lots of tables, and working with a model with 200 entities in it will be a pain. Therefore, we decided to split models according to modules. Therefore, the user module with have its own model, the permission module will have its own model and so forth. I will try the solution you offered of putting all the migrations in a single assembly and see if that works. Regards. |
|
|
Hi, I've set the same migrations project for all of my migrations, yet the problem persists. No matter in which order I attempt to do the upgrade, it fails because it depends on a table that has not been created yet. What is the correct way to get around this, keeping in mind that we would ideally like to keep models apart on a per module basis. Regards. |
|
|
Do you still have your migration methods split between the 3 models though? e.g. Each model has its own initial migration method? If so you need to merge these into a single method and order the create table calls based on the FK dependencies.
|
|