How can I get a PDB file for the EntityFramework NuGet package?
Asked Answered
K

3

33

I'm trying to debug a StackOverflow in the EntityFramework NuGet package (version 6.1.3). In order to see the stack frames I need the PDB file for EntityFramework.DLL and EntityFramework.SqlServer.DLL. However, I can't seem to get Visual Studio to download this from either the MSFT symbol sources or from SymbolSource.org (I can get other System PDBs and things like NewtonSoft.json). Are the EF PDBs available anywhere?

Kornher answered 19/8, 2015 at 20:19 Comment(1)
Did one of these answers worked for you?Tychonn
S
30

Now with pictures (as it took me about an hour of trial and fail)

  1. Get DotPeek from Jetbrains (Standalone version)

  2. Open DotPeek -> File -> Open -> browse to your project bin folder and open EntityFramework.dll

  3. Right mouse button on EntityFramework then choose Generate Pdb... enter image description here

enter image description here

  1. Go to folder where you exported it and open EntityFramework.pdb folder (I know right!) then dig deeper till you find a file EntityFramework.pdb and copy it to your bin folder (next to EntityFramework.dll).

  2. Go to Visual Studio -> DEBUG -> Options and Settings... -> Symbols then add your bin folder to Symbol file (.pdb) locations

enter image description here

  1. Run project and pray those breakpoints turn ripe red....

Edit: It sometimes starts running EF in optimized mode that renders debugging pretty much useless which is a whole point of this question - if this happens

  1. Go to Visual Studio -> Debug -> General -> (at the very bottom) Use Managed Compatibility Mode. Tick and Run project (if it gets optimized then untick and run, then tick again and run, then ....)

enter image description here

  1. To see if EF runs optimized without having to wait till it hits breakpoint Go to Visual Studio -> Debug -> Windows -> Modules. Then when you run solution modules (2) should appear. Click it and find EntityFramework.dll there should be column that says Optimized(Yes = bad, No = you can debug it).

enter image description here

Hope this saves you some time.

Sergiosergipe answered 23/6, 2016 at 14:22 Comment(4)
Great explaination @Matas! Thx!Tutuila
It seems that DotPeek doesn't hook itself to VS2017, but you can do the same process by using the GUI that is installed along.Discard
For anyone else who is still setting Optimizations on there dll make sure the Supress JIT Optomization on Module load is checkedYelenayelich
Do you really need to do step 5 if you already put the .pdb in your bin directory? I mean, you will have to change it for every project if you hardcode it...Norland
K
13

Download the source code: entity framework on codeplex

The download button is in the sub-menu on the Source tab

Once downloaded:

  • Build the solution/project

  • Navigate to the bin directory NB: it is not in the normal location, its set to "..\..\bin\Debug\". See Project properties.

The EntityFramework.pdb and the EntityFramework.SqlServer.pdb are both there.

Also would of thought, it would be available by default or easier.

Kilo answered 16/10, 2015 at 6:25 Comment(5)
I can't believe that this is the only answer to this questionMarxmarxian
I'm surprised i didn't get any cred, #justsaying ;-) totally agree tho... had to dig to only get to this...Kilo
up for the exclusive (albeit not satisfying) answer to this questionMarxmarxian
One note: I didn't need the pdb file myself. I was hoping to get more info of my Exception. But the info was already there. I just had to inspect the $exception variable in the local variable window of visual studio.Marxmarxian
The problem with this answer is that it has to be the exact same version that you are running in your project. And EF hasn't always had a sensible versioning schemeIcosahedron
P
4

One of the ways is to use dotpeek as symbol server (load entity framework dll and add dotpeek serer address copied from dotpeek settings) - what is great about this approach, that it generated pdb matching used dll version automatically, what is not so great - it will not contain original comments from source code, etc.

Phosphatase answered 11/2, 2016 at 11:19 Comment(1)
This also works without the Symbol Server mode. You can generate a pdb file for an assembly and point Visual Studio to the folder dotPeek creates.Karafuto

© 2022 - 2024 — McMap. All rights reserved.