efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Error: Script-Migration -Idempotent -Context "MyDbContext" -StartupProject "MyStartupProject" -Project "MyDataProject"

Open gorgasparyan opened this issue 1 year ago • 10 comments

Script-Migration : Error HRESULT E_FAIL has been returned from a call to a COM component. At line:1 char:1

  • Script-Migration -Idempotent -Context "AoaDbContext" -StartupProject ...
  •   + CategoryInfo          : OperationStopped: (:) [Script-Migration], COMException
      + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Script-Migration
    
Screenshot 2024-02-16 165210

gorgasparyan avatar Feb 16 '24 13:02 gorgasparyan

happening with VS 2022 17.9.0

mcabrerawellgatetechcom avatar Feb 16 '24 22:02 mcabrerawellgatetechcom

I had to revert to using the dotnet cli ef core tools to generate my script. Does seem like an issue with Visual Studio.

JustinJmnz avatar Feb 17 '24 05:02 JustinJmnz

dotnet cli ef core tools to generate my script

Thanks Justin, I also tried and dotnet cli ef core tools did generate the script. Here is the command: dotnet ef migrations script --idempotent --context "MyDbContext" --startup-project "MyStartupProject" --project "MyDataProject"

gorgasparyan avatar Feb 17 '24 08:02 gorgasparyan

Same issue on VS 2022 17.9.0

carlaguinaldo-TU avatar Feb 19 '24 07:02 carlaguinaldo-TU

This bug also affects VS 2022 17.10 Preview 1.

phillipmunn avatar Feb 19 '24 11:02 phillipmunn

This issue appears to be the same as this one below, which is that .sql files cannot be viewed in Visual Studio. I'd use the CLI version above to workaround this for now.

https://developercommunity.visualstudio.com/t/sql-Files-cannot-be-opened/10584835 https://developercommunity.visualstudio.com/t/open-sql-in-visaul-studio-after-upgrade/10584421

phillipmunn avatar Feb 19 '24 11:02 phillipmunn

I'm getting this problem in the latest preview and the normal release of Visual Studio.

Mark-Phillipson avatar Feb 19 '24 17:02 Mark-Phillipson

Same issue here as above on latest VS 2022

Dave-Townsend avatar Feb 19 '24 19:02 Dave-Townsend

I have found that if you change the application that is used to open an SQL file in Visual Studio, it solves the problem.

Mark-Phillipson avatar Feb 20 '24 10:02 Mark-Phillipson

I have found that if you change the application that is used to open an SQL file in Visual Studio, it solves the problem.

How can that be done?

Danotsonof avatar Feb 21 '24 07:02 Danotsonof

I have found that if you change the application that is used to open an SQL file in Visual Studio, it solves the problem.

How can that be done?

I found a way to set a default sql viewer by following the accepted answer here: https://stackoverflow.com/questions/2193083/visual-studio-open-a-sql-file-with-sql-management-studio-in-an-existing-ssms-w

Danotsonof avatar Feb 21 '24 08:02 Danotsonof

I experienced the same issue, the latest vs release mentions a similar Developer Community problem:

.sql Files cannot be opened

I've since updated to VS 17.9.1 and scripting migrations is working again.

tp1045 avatar Feb 22 '24 16:02 tp1045

Yeah, it works after the latest 17.9.1 update.

gorgasparyan avatar Feb 22 '24 16:02 gorgasparyan