Debugging the Package Manager Console

I love doing EF Code First development, but sometimes it’s hard to know what’s going wrong when you issue commands like ‘Update-Database’ when doing Migrations. Often the error text doesn’t give any clues to the root cause and you’re left scratching your head.

Well, stop scratching and put these two lines of code in the method (at the top) you’re having trouble with, such as the ‘Seed’ method:

if (!System.Diagnostics.Debugger.IsAttached)

Build and rerun your command in the Package Manager Console and you’ll be prompted to open a new instance of VS that will allow you to debug your code and save you a lot of time.

Happy coding and I hope this helps!

Lose our keys, please!

Rental Car Keys

Gripe #818302b: What’s wrong with car rental companies?  Oh, sorry, that was far too broad of a question, wasn’t it?  Specifically, when I rent a car these days almost all car rental companies give me a key ring which contains BOTH of the car keys, which are identical, along with a tag saying that they’ll charge me some outrageous fee if they’re lost.  To top it off, the key ring is crimped closed and cannot be opened without cutting the cable.  God only knows what the cable would cost me if I cut it.  Perhaps they don’t make enough money renting cars anymore and need to supplement their income via other silly ways.  Want to talk about insurance coverage next?  :)

OneNote corruption

Error Message:

Microsoft OneNote

OneNote cannot pack these sections because some sections have not yet been fully synced and could not be downloaded. These pages will not be saved.

Continue anyway?

(Hell no!)

I’m adding this entry for those that see this error and cannot get around it via other suggestions, and because I couldn’t find an answer for my particular scenario on the web. I spent hours figuring this out and want to help anyone else who may be facing the same problem.  Lastly, perhaps someone at Microsoft will take me up on my offer at the bottom of this post.

      • I use OneNote 2013.  You mileage may vary.  I doubt the OS matters.  I LOVE OneNote and couldn’t image being without it.  I use it all day, every day.
      • In my case, the problem only appears when I use the notebook export function which packages the sections and files, and only when you export the entire notebook, not just one section.
      • Out of my 3 notebooks two of them demonstrated this error.  As it turned out, I had one ‘corrupt’ file in each of the notebooks.  Different notebooks, different sections, different files. The files are unrelated.
      • The problem follows the corrupted page, so if you move it to another section or notebook the problem will move with the page.
      • Don’t bother looking for anything abnormal, it’s not visible.  The corrupt page can have nothing on it and still block your export.  Now isn’t that sweet, how did I achieve that? :(
      • It doesn’t matter if the notebook is shared or not.  For that matter, it doesn’t matter if the notebook is located on OneDrive or your local desktop.  If you have a corrupt file the problem will surface either way.
      • The export function doesn’t include deleted files, so to find your ‘corrupt’ page simple delete all the sections in your notebook and slowly add them back in, one at a time, stopping to perform a notebook export each time to see if the section or file you just added back is the problem.  Yes, this is time consuming, but it works.
        • Personally, to do the above, I created a new local ‘test’ notebook and then copied each of my sections from the problematic notebook into the new test notebook, just for extra safety and speed.  I closed my main notebook to avoid move/delete confusion while testing.  You’ll be doing a lot of moves, deletes and exports while trying to isolate the corrupt file.
        • In case you don’t know this, you can right-click on the notebook name in question and select ‘Notebook Recycle Bin’ to get to your deleted files.  To leave the recycle bin just click on the notebook name again.  Sometimes you have to right-click and de-select ‘Notebook Recycle Bin’.
        • I went the route of starting with everything deleted because of the time it takes to pack the files and wait for the error to appear.  The packing is much faster with fewer files, obviously.
        • Once you find the section that blocks your export you then have to narrow it down to the page.  Follow the same procedure you did with the sections – delete all pages and add them back in systematically until you isolate the problem page.

I placed my two corrupt pages in a notebook and can send them to Microsoft (or anyone else for that matter) upon request.  It’s an interesting and esoteric bug.

The best of luck to you.

Created with Microsoft OneNote 2013.  J

“You’ve got to find what you love…”

The title is a snippet out of the text of a Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005, and, oddly enough, is close to what we at Palatic live by.  Do what you love, and love what you do.

This blog is a collection of thoughts by the principals of Palatic Inc., a for-profit corporation residing in the state of Washington, USA.  Topics will be random in nature, but hopefully you’ll find some of the posts interesting and helpful to you.  If not, at least we’ve saved a ton of money on psychotherapists through our writing exercises.