-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations being generated for a context that I don't want #42
Comments
Seems there's a bug (it should be giving you an error though). But anyway, you need to enable migrations for your DbContext before calling "migrations add". But the "migrations enable" command is faulty it seems, it does not accept a context. Will fix this soon. |
Should be fixed in Note that if you want to work with migrations for more than one context you should specify and output directory for each:
It's very important that migrations from different contexts live in different folders and different namespaces. |
I updated, did a complete clean, dotnet restore, and deleted all my migrations folders. I then called these commands:
However still in EdwMigrations everything from DrsDbContext is there, and in Migrations, everything from EdwDbContext is there. |
Sorry, will give this some time soon and try it with a project from scratch. I tested it really fast and it seemed to be working 🏃 😅 |
@armille3 tried doing the exact same commands in your last comment in a new project and it worked. Can you provide a repro if you're sure you're still experiencing the same issue? |
See attached for a simplified example of my project with this problem. The connection string will need changed in Drs.Framework.Repositories.CoreApiInitializer. |
Just tested it, and yeah the problem occurs. Maybe it's the way you're structuring the files. I'll investigate more. |
@armille3 I tried hard to reproduce the problem from a new project but I couldn't. Tried putting all the models in the root namespace, and still worked. The problem is only happening in the project you sent. Not sure what I can do at this point since your project is too complex to figure out what's happening. If you can reproduce this in a minimal simple project I might be able to help. |
I noticed that if I give it a fake DbContext name, it continues anyways without a warning. For example:
I am going through your code trying to find anything. |
I ended up getting around this by placing my other context in another project. What I think is causing this however is the mappings. I'm guessing if I delete the mappings from the other context in the project, it would work fine. |
The mappings? In any case, good to hear you got around it. |
Yeah, the EntityTypeConfigurations. You can do this either by attributes, or how I do it via a mapping class.
|
Oh. Hmm, can't see how this might be a problem for "Migrator.EF6" itself. I'm not doing anything special here. But I'll investigate a bit more when I have some time. Thanks! |
I am running the following command:
dotnet ef migrations add "CatchUp" -c DrsDbContext
However, when I look at the "CatchUp" migration, it is generating code that is using the EdwDbContext, which I do not want.
The text was updated successfully, but these errors were encountered: