locked
VS2012 package manager crashes on update-database using entity first code migrations with seed RRS feed

  • Question

  • I am working through this tutorial  http://www.asp.net/mvc/tutorials/getting-started-with-ef-5-using-mvc-4/creating-a-more-complex-data-model-for-an-asp-net-mvc-application and have successfully reached almost the end of this step. 

    Problem is that when I come to do the last update of the database as mentioned  near the very bottom of the page "After you have finished editing the <timestamp>_Chap4.cs file, enter the update-database command in the PMC to execute the migration." as soon as this starts VS2012 crashes and reports that it stops working and then restarts having kicked me out of the project. 

    I can do this update from within code: (added the following code to the 'about' controller so it runs everytime I navigate to 'about':

    var configuration = new Configuration();

    var migrator = new DbMigrator(configuration);
                migrator.Update();

    This works without issue. I can place a breakpoint in the ef SchoolContext derived from dbContext where a seed method runs that populates the database with data. Ths works ok.

    Why is vs2012 crashing when I use update-database from within the package manager but not when I do the same in code?

    Throughout the rest of this tutorial the package manager has worked ok.

    Have no idea how to troubleshoot vs2012 crashing either.

    Can anyone shine a light onto this issue? Thanks

    Edit - the second time I tried this from the PMC I saw the message that no migrations were pending, then message 'running seed' at which point vs2012 stopped working crashed and restarted. This makes me wonder if I need to re-edit the seed  method as the update database schema worked, although the fact that I can run this from within code suggests some other issue in vs2012.


    • Edited by DiggerMeUp Tuesday, December 17, 2013 9:30 AM edited title
    Saturday, December 14, 2013 10:40 PM

Answers

  • Hello,

    >>Was the code invoked break-point causing the crash? Certainly appears so as un-commenting this line crashes vs2012 again.

    Does it mean that if you comment this line then VS2012 will not crash?

    Have a try to add a break point with ‘F9’ to see whether it will crash again.

    When the project crashes, does it throw any error message? If it has, please share it with use so that we could help you better.

    Regards.

    Hi,

    Yes, I did a test which is similar with yours and the VS crashed, too. (:-O)

    I also found that even if I written a simple console application like below:

    class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                System.Diagnostics.Debugger.Break();
    
            }
    
        }
    

    Then I run it from without the VS, the application crashed, too.

    As far as I know, the System.Diagnostics.Debugger.Break() should only be used when program is in development model. It should not be existed in an integral application.

    The PMC is an integral tool, when we use the command like “update-database”, we are running the application directly, when it met the System.Diagnostics.Debugger.Break(), it stoped work and the VS crashed.

    So if you want to debug the program, I suggest using the “F9” to add breakpoint.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by DiggerMeUp Monday, December 23, 2013 10:49 AM
    Tuesday, December 17, 2013 8:19 AM
  • Hello,

    Sorry for being late.

    >>Is there any other way to issue commands with the PMC and 'step into the code'? 

    As far as I know, there is no such command which can step into the code.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by DiggerMeUp Monday, December 23, 2013 10:49 AM
    Monday, December 23, 2013 8:14 AM

All replies

  • I was playing around with this some more and commented out

    System.Diagnostics.Debugger.Break()

    that I added in the Seed method within the migrations configuration file. I could run update-database and run the seed method both from the PMC ok.

    Was the code invoked break-point causing the crash? Certainly appears so as un-commenting this line crashes vs2012 again.

    Saturday, December 14, 2013 11:35 PM
  • Hello,

    >>Was the code invoked break-point causing the crash? Certainly appears so as un-commenting this line crashes vs2012 again.

    Does it mean that if you comment this line then VS2012 will not crash?

    Have a try to add a break point with ‘F9’ to see whether it will crash again.

    When the project crashes, does it throw any error message? If it has, please share it with use so that we could help you better.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 16, 2013 6:13 AM
  • Hello Fred,

    >>Does it mean that if you comment this line then VS2012 will not crash?

    - Yes.

    I have attached a screen shot below of the where line 20 shows the break point in code which when commented out causes no crash. The PMC shows "running the seed" method at which point the "stopped working" dialog pops up and closes vs2012. This should be repeatable. Was trying to find a way of updating the database from the pmc and stepping through the code (as an aid to trouble shooting any future issues ) to gain greater visibility into the process.

     thanks.

    Monday, December 16, 2013 10:33 AM
  • Hello,

    >>Was the code invoked break-point causing the crash? Certainly appears so as un-commenting this line crashes vs2012 again.

    Does it mean that if you comment this line then VS2012 will not crash?

    Have a try to add a break point with ‘F9’ to see whether it will crash again.

    When the project crashes, does it throw any error message? If it has, please share it with use so that we could help you better.

    Regards.

    Hi,

    Yes, I did a test which is similar with yours and the VS crashed, too. (:-O)

    I also found that even if I written a simple console application like below:

    class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                System.Diagnostics.Debugger.Break();
    
            }
    
        }
    

    Then I run it from without the VS, the application crashed, too.

    As far as I know, the System.Diagnostics.Debugger.Break() should only be used when program is in development model. It should not be existed in an integral application.

    The PMC is an integral tool, when we use the command like “update-database”, we are running the application directly, when it met the System.Diagnostics.Debugger.Break(), it stoped work and the VS crashed.

    So if you want to debug the program, I suggest using the “F9” to add breakpoint.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by DiggerMeUp Monday, December 23, 2013 10:49 AM
    Tuesday, December 17, 2013 8:19 AM
  • Hello Fred,

    Thanks for the reply. Thats interesting regarding vs2012 stopped working in a console, had not tried that. Certainly explains the behaviour I am seeing.

    Problem is that the program is not running in debug mode so 'F9 to add a breakpoint' will not work with the PMC as the program will never stop when it hits that line. 

    Is there any other way to issue commands with the PMC and 'step into the code'? 

    Thanks


    • Edited by DiggerMeUp Tuesday, December 17, 2013 9:33 AM
    Tuesday, December 17, 2013 9:30 AM
  • Hello,

    Sorry for being late.

    >>Is there any other way to issue commands with the PMC and 'step into the code'? 

    As far as I know, there is no such command which can step into the code.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by DiggerMeUp Monday, December 23, 2013 10:49 AM
    Monday, December 23, 2013 8:14 AM