C
C#3d ago
Jorjo

dotnet ef migrations add init returns: 'Unable to retrieve project metadata.'

Just what it sounds like in the title, ef is being difficult and won't make a migrations folder which I need in order to test with. My installed sdks are 8.0.100, 8.0.405 and 9.0.203. I am on Arch Linux but installed these through the install script from microsoft. As for EF Tools I'm using version 9.0.0 but have also tried 9.0.2 and 9.0.4, neither worked and the same error is returned each time. I have tried running the command with --msbuildprojectextensionspath and it yielded the same result. I'm getting kind of hopeless, I've never before experienced this kind of error and migrations have worked just fine in other projects. Any help is greatly appreciated.
No description
30 Replies
Pobiega
Pobiega3d ago
leads me to think something aint right with your installation
No description
Pobiega
Pobiega3d ago
whats the output if you do dotnet --list-sdks?
Jorjo
JorjoOP3d ago
No description
Pobiega
Pobiega3d ago
hm okay so this is only a problem when running via dotnet ef?
Jorjo
JorjoOP3d ago
yeah basically only when trying to make inital migrations with dotnet ef
Pobiega
Pobiega3d ago
what does your project structure look like? are you in a project folder when running the command? if so, show the .csproj for that project
Jorjo
JorjoOP3d ago
No description
Jorjo
JorjoOP3d ago
Just a simple ASP WebApi
Pobiega
Pobiega3d ago
yeah looks right at a glance... lets try explicitly indicating the project.. dotnet ef migrations add --project Backend.csproj Initial
Jorjo
JorjoOP3d ago
No description
Jorjo
JorjoOP3d ago
and I'm still in the same dir so it's not as if I'm not referencing it directly
Pobiega
Pobiega3d ago
hm, yeah something is going wrong when dotnet ef is trying to run other commands.. at least, thats my guess I wonder if we can bypass it... probably not. Worth a try. dotnet ef migrations add init --no-build it still needs to start the app to resolve the context
Jorjo
JorjoOP3d ago
I could run clean and remove the previous build iterations but trust me I've already done it, and no luck, also sorry if I'm putting you on a wild goose chase it's been bugging me all day so I had to get some exposure to it because I can only find maybe 3 google results about this, and it's so annoying.
No description
Pobiega
Pobiega3d ago
yeah idk its deffo related to how dotnet ef calls other commands internally, but Im not sure how to fix it
Jorjo
JorjoOP3d ago
that's fair I've already looked into it plenty myself and I think it's a bunch of baloney, I tried running it through a chatbot and it seems to think it has to do with .target files in /obj and I'm not really sure why that would be the culprit I haven't changed any default behavior that would cause it to alter any metadata.
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jorjo
JorjoOP3d ago
ok so one thing, since maybe 10 min before you wrote this I have removed all sdks and reinstalled just version 9.0.203 and ran dotnet tool install --global dotnet-ef, and now I get the error in the picture bellow
No description
Jorjo
JorjoOP3d ago
I'll try that I tried it the new tool-manifest along with installing dotnet-ef locally but I just get this error again
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jorjo
JorjoOP3d ago
and I uninstalled it from global
No description
No description
No description
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jorjo
JorjoOP3d ago
No description
Jorjo
JorjoOP3d ago
closed them, and killed my tmux server so that it wouldn't run a session in the back idk what I just did
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jorjo
JorjoOP3d ago
but it works
No description
Jorjo
JorjoOP3d ago
Jesus christ
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jorjo
JorjoOP3d ago
maybe idk :droidcry: im just happy it works atp
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jorjo
JorjoOP3d ago
this absolutely drained me today thank you I didn't think that global would be a culprit but I guess somewhere along the way of reinstalling sdks and exporting variables correctly it went right I just killed my tmux session and ran dotnet clean after running rm -rfd in ~/.dotnet/sdk/9.*/Current/SolutionFile/, then ran the migrations command and it worked Thanks once again, I'll close this thread now.

Did you find this page helpful?