Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find the console or debug output from code executed in the package manager window?

I'm using EntityFramework code first with migrations. From the package manager console, I'm running "update-database". This executes Configuration.Seed(context) which I have overridden.

    protected override void Seed(WebContext context)     {          Console.WriteLine("Console Test");         Debug.WriteLine("Debug Test");         Trace.WriteLine("Trace Test");     } 

Where can I find that output?

Better yet, How do I output back to the package manager window?

Thx, Dan

like image 943
DanielEli Avatar asked Mar 30 '12 13:03

DanielEli


People also ask

Where can I find Package Manager console?

Console controls To open the Package Manager Console in Visual Studio, select Tools > NuGet Package Manager > Package Manager Console from the top menu.

What is Package Manager console?

The NuGet Package Manager Console uses NuGet PowerShell commands to find, install, uninstall, restore, and update NuGet packages. The console is built into Visual Studio on Windows.

Where is Package Manager console in Visual Studio Mac?

To open the console in Visual Studio, go to the main menu and select Tools > NuGet Package Manager > Package Manager Console command.

How do I write to the Output window in Visual Studio?

You can write run-time messages to the Output window using the Debug class or the Trace class, which are part of the System. Diagnostics class library. Use the Debug class if you only want output in the Debug version of your program. Use the Trace class if you want output in both the Debug and Release versions.


2 Answers

A quick hack I use to be able to quickly find a value in my Seed method is simply to throw an exception with a value I care about, e.g.

throw new Exception(yourValue); 

This errors out the Seed, but my exception/value appears in my package manager console.

like image 84
George Johnston Avatar answered Oct 26 '22 04:10

George Johnston


Where can I find that output?

Sorry, but the quick answer is basically nowhere.

To be precise at least not in the package manager console.

Debug.WriteLine("Debug Test"); Trace.WriteLine("Trace Test"); 

You can see the output of the Debug... and Trace... methods if you attach another Visual Studio to debug the Visual Studio instance which is running the update-database command. Then in the debuggin VS you can see the output in the Output Window.

Console.WriteLine("Console Test"); 

You can see the output of the Console... methods if you run the migrations with the migrate.exe command line tool which comes with EF:

enter image description here

How do I output back to the package manager window?

I have here also bad news, after a quick "reflectoring": with the current implementation of the EF migrations it's not supported to display custom information during execution of the update-database (or any other command).

like image 45
nemesv Avatar answered Oct 26 '22 03:10

nemesv