Nice little gotcha when getting started with Entity Framework using the built-in ASP.NET MVC templates. Wanting to start from a fresh database using the MSSQLLocalDB there is a few little things to do that aren’t necessarily obvious:
1. Delete the mdb and ldf
Go to the App_Data directory and delete.
If the delete fails, make sure you stop IIS Express which is holding a handle to the files.
If the delete still fails, make sure you have closed connections in the server explorer in Visual Studio.
Still failing to delete? Go to Task Manager and kill the SQL Server Windows NT [sqlservr.exe] process.
2. Run Update-Database from the Package Manager Console
Fails with “The EntityFramework package is not installed on project ‘####’.”
Check the default project is set to the correct one which contains the Migrations folder. Mine keep defaulting back to the Tests project.
Fails with “Cannot attach the file *.mdf as database”.
I found the answer on StackOverflow. The default connections string contains the
Initial Catalog property. Which is all good for a full SQL Database but not LocalDb. Removing that property and it is all good.
Entity Framework seems quite good with Code First Migrations. I find the documentation really hard to get up to speed if you are coming new to it. Much of the documentation seems to focus around the difference and pieces together what to use for the latest version wasn’t the simplest. There is a bunch of little things you need to be aware of and practice with Add-Migrations and making sure everything is upgradable properly. Persisting with it [pun intended] has been worthwhile so far…
Everything compiled fine and the app is running well. However when I attached the debugger to w3wp.exe and however over variables, no value was being shown. Ctrl-Alt-Q on one for Quick Watch revealed the problem.
error CS1704: An assembly with the same simple name ‘###’ has already been imported. Try removing one of the references (e.g. ###.dll) or sign them to enable side-by-side.
Error seems straight forward enough. Help points to fixing references as the error would suggest. This only just started happening. And not just me. So it must be a code change right? Looking through version history, everything looks innocent. I check the references and they are all fine. So I must have some messed up assemblies somewhere.
Clean entire workspace. tfpt treeclean
Restart visual studio.
Rise & Repeat…
No avail. Both my git and TFVC workspaces have the same problem.
Reboot computer in case of cache.
Then I delete the Temporary ASP.NET Files for the web site in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files.
Bingo! Some change must have caused a duplicate to be place in there somehow. Not the best resolution, but as least I can inspect the code with the debugger again.
I have been using Office Lens for a while now. Every time I have a use for it I am blown away at how good it is. This tool works well in real life and not just the demo scenarios shown on product pages.
Office Lens trims, enhances and makes pictures of whiteboards and docs readable, and saves them to OneNote. You can use Office Lens to convert images to PDF, Word and PowerPoint files too. Office Lens is like having a scanner in your pocket. Like magic, it will digitalize notes on whiteboards or blackboards. Always find important documents or business cards. Sketch your ideas and snap a picture for later. Don’t lose receipts or stray sticky notes again! You can convert your pictures to PDF files with selectable text, in addition to Word and PowerPoint files, and save them to OneDrive.
I was at a training day on the weekend. Here is the shot I got with the Lumia 930:
Here is the slide captured by Office Lens:
Here is one of my boys’ drawings never to be lost:
You can include up to 10 photo’s within the one document. I use it for receipts, business cards, kids drawings, white board sketches and notes, handouts from school. It is then uploaded to OneNote (now completely free), which is what I use for all and any note taking. As a hoarder by nature, having a digitalization path so quickly to get rid of the clutter is fantastic.
Get it from the Windows Phone Store for Windows Phone, iTunes for iOS or sign up for the Preview for Android.
Argh!! Another very unhelpful error message:
What am I supposed to do with that? Today I found out what. Run the command again with –d for debug.
And there is the message that should be have been with the error code:
fatal: Unable to create ‘C:/Code/Main/.git\tfs\default\index.lock’: File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
I can work with that. There were no other git processes running, but the file
.git\tfs\default\index.lock did exist. Deleting that we get further, this time with a very helpful error message:
Run the command:
git tfs cleanup-workspaces
Looks good. Run the pull again and we are back in business.
I don’t know if it is the files I have on my computer, but each of my machines’ index file size occasionally just goes out of control. This covered KB 2838018 The Windows.edb file grows very large in Windows 8 or Windows Server 2012. Unfortunately however even after the hotfix is installed, as seen below, 66 GB for the index on a 439 GB drive seems very much like the symptom described.
The instructions in the KB cover how to rebuild the index. I find just stopping the indexing services, deleting the file and restarting the services a quicker space recovering resolution. Note that your search everywhere in Windows, even applications from the start menu, won’t work for a little while.
Finding space to free and finding this rogue file is very easy with Space Sniffer, it is the best disk space visualization since Space Monger 1.4. Be sure however to run it as Administrator, otherwise those system files will not be shown.
The file is located at
C:\ProgramData\Microsoft\Search\Data\Applications\Windows. After a rebuild it is a more reasonable 1.8 GB.
I have an IIS application that is querying Azure Active Directory Graph API from the server. I wanted to capture what is requests are happening using the client API. By default Fiddler does not capture these requests. Fiddler inserts itself into the WinINET layer as a proxy which is bypassed by IIS outgoing traffic.
To capture these requests coming from an IIS application pool. Add to your web.config after the <configSections> element:
<proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>
where 8888 is the fiddler listening port, found in Tools > Fiddler Options
This can be found in the Fiddler documentation.
Happy web traffic debugging!
I did not want to move my laptop and plug it into the TV via HDMI and use my Wireless Notebook Presenter Mouse 8000 as I normally do. So I thought I’d try a complicated way to get the slides on the TV.
Firstly, I need to the presentation shared. PowerPoint has this feature, Present Online.
Secondly, I needed a browser on the TV. I don’t have a Smart TV. For all that functionality I use my Xbox 360. On it goes and I launch Internet Explorer which I can fortunately do now without an Xbox Live subscription.
Thirdly, I have a giant URL I need to type in for the presenting online presentation. Doing that on the Xbox controller would be horrible, especially since I can’t see the computer screen and TV at the same time. Instead I connect to the Xbox via Smart Glass from the laptop running the presentation. Here I can just launch the remote control and copy and paste the URL right into the Xbox 360 browser.
Fourthly, I need to control the slide show in front of the TV away from computer. I could just use my Bluetooth presenter mouse. The downside to that however is that I would be missing out on my slide notes. Microsoft has recently released Office Remote. It’s a Microsoft Office add-in with a Windows Phone app. So connecting my phone to my PC via Bluetooth and connecting Office Remote I get slide navigation, speaker notes and more presenter mode features.
Although this is overly-complicated and many moving parts it all connected quickly and easily and gave a good experience. Just goes to show how many options we have to do simple things, and that is just on the Microsoft stack. This was more for experimenting with what could be done. I would not recommend it!