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.
30 Replies
leads me to think something aint right with your installation

whats the output if you do
dotnet --list-sdks
?
hm okay
so this is only a problem when running via dotnet ef?
yeah basically only when trying to make inital migrations with dotnet ef
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

Just a simple ASP WebApi
yeah looks right at a glance...
lets try explicitly indicating the project..
dotnet ef migrations add --project Backend.csproj Initial

and I'm still in the same dir so it's not as if I'm not referencing it directly
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 contextI 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.

yeah idk
its deffo related to how
dotnet ef
calls other commands internally, but Im not sure how to fix itthat'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•3d ago
Message Not Public
Sign In & Join Server To View
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

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•3d ago
Message Not Public
Sign In & Join Server To View
and I uninstalled it from global



Unknown User•3d ago
Message Not Public
Sign In & Join Server To View

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•3d ago
Message Not Public
Sign In & Join Server To View
but it works

Jesus christ
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
maybe idk :droidcry: im just happy it works
atp
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
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.