# Visual Studio Code Snippets to Make Coding EF Core a Little Simpler

I’ve been using the user snippet feature of Visual Studio Code to make it easier to get some of the code I commonly use for EF Core into my files. For example I have C# snippets for DbContext to create a constructor overload that takes in a DbContextOptions parameter, OnConfiguring or OnModeling . I have json snippets to add in the EFCore Commands dependency and the Tools section with EF Core tools.

github.com/julielerman/EFCoreSnippetsForVSCode

I finally created a github repository to share them. Since you’ll need to add the csharp snippets into your existing csharp snippets and the same with the json, i have put them into separate csharp.json and json.json files from which you can copy and past my snippets into your own.

Although the instructions are on the user defined snippets page I just linked to, the TL;DR is:

From menu, choose Code, Preferences then User Snippets

That will open a list of snippet files. Choose C# for the C# snippets and Json for the Json snippets. Paste in my snippets!

# Video of My .NET on a Mac Demo at DotNetFringe

Last week at the awesome DotNetFringe conference in Portland, Oregon, I did a 30 minute demo of building an ASP.NET Web API with Entity Framework using Visual Studio Code on my lovely MacBookPro. So it’s .NET on a mac (coding, debugging and running). It is *that* cross platform.

I also talked about some of the features of ASPNetCore and EFCore. I used other cross platform stuff like JetBrains’ DataGrip IDE for interacting with numerous databases on numerous platforms, PostgreSQL database, xunit for testing and more!

The solution I showed in the demo is in my github repository: julielerman/EFCore-ASPNetCore-WebAPI-RTM

# Specifying Global TypeScript server path in Visual Studio Code in OSX

Since I’m really new to working on a mac, the instructions on the VSCode blog post (http://blogs.msdn.com/b/user_ed/archive/2016/02/09/visual-studio-code-new-features-javascript-salsa-preview.aspx) for enabling Salsa for TypeScript in VSCode was just not enough for me. This is the instruction:

You then have to tell VS Code the install location using the typescript.tsdk setting. Set typescript.tsdk to the path of thelib folder containing the tsserver.js file of the installed TypeScript module.

I had done a global install. And since hidden files and the usr/ folder are also a mystery to me, it took me a while to figure out that this is how to specify that in the settings.json file in VSCode.

“typescript.tsdk”: “usr/local/lib/node_modules/typescript/bin/tsserver”

I hope someone can save some time by finding this blog post.

# Visual Studio 2015 Update 1: EXE Install vs Control Panel Install

tldr; my recommendation is to just do the update from control panel, not from the VS2015.1.exe

If you follow me on twitter (@julielerman) you may have caught one of my tantrum driven tweets yesterday about problems with IISExpress after I updated Visual Studio 2015 to Update 1.

I finally resolved my problems but not after a lot of whining, chocolate and avoidance measures (including a Doctor Who Season 9 episode).

I had been avoiding the update since a number of folks had been complaining about it taking hours and hours but I finally decided to bite the bullet.

I initially updated by downloading the vs2015.1.exe via VS2015 Extensions and running that. It didn’t take too long (20 minutes maybe) but in the end reported that Microsoft .NET Framework 4.6.1 RC Developer Pack had not been installed. This is a known issue. I restarted and installed that and was rewarded with “Successfully installed”.

Then I opened up an ASP.NET MVC5 (*not* the new asp.net) app I’d been working on and tried to run it and so began my problems with IISExpress. Visual Studio could not launch it. I won’t go into the many and various things I tried for the next few hours with hints from friends on twitter and many stackoverflow and blog posts. I even uninstalled and reinstalled IIS 10.0 Express a few times and tried various security/permission tweaks as well. I had offers from friends to jump on skype to help and finally took one of those up – thanks Gregor Suttie (@gsuttie) – though we still made no headway.

There was another strange problem that is noteworthy. Although Visual Studio’s Help/About window showed that I had the version # for Update 1 installed, the Extensions dialog continued to show Update 1 as an available update to Visual Studio. Something wasn’t in sync.

Others on twitter reported issues with Update 1, even Barry Dorrans (@blowdart) who is a security expert on the ASP.NET team and Jeff Prosise (@jprosise), a renowned .NET super duper uber expert.

I decided it was time to just uninstall and reinstall VS2015 – cleaner than a repair in my mind. Though I hadn’t yet determined if I would apply the Update 1 again.

I opened up Control Panel/Programs, found Visual Studio Enterprise in the list and selected it. I immediately got a notification that the setup program for Visual Studio had changed significatnly and did I want to update that before making any changes to the installation.

Even though my plan had been to uninstall, I decided to take that path. The update took some time … I think over 1/2 hour.

When it was done, Update 1 was one of the options listed when I chose to Modify.

FWIW, after performing the update, you can’t uncheck that option.

I selected the Update 1 and didn’t touch anything else and let ‘er rip (e.g. clicked the Update button).

It took some time to update and it was nice to see that it also brought in the latest version of the EF Designer (6.1.3) for me. “some time” ….I didn’t keep track at all …went upstairs for dinner.

When all was said and done, all of the problems I had seen via the exe install were gone. Update 1 was in place. Extensions no longer prompted me to install the update. I could debug in IISExpress again. All of my other extensions were still in place. (Update: nuget was gone, so I had to reinstall that.)

Oh and I had the new icon which many had fought so hard for:

So my recommendation is to just do the update from control panel, not from the VS2015.1.exe!!

# Is Visual Studio Code Bugging You For Your User Name and E-Mail Address?

Are you seeing this message when trying to push changes from Visual Studio Code to github?

It turns out that all of those times I’d been pushing/pulling from the command prompt and entering my name and email each time could have been avoided with the same configuration. But Visual Studio Code wasn’t going to let me get away with that laziness.

I finally GoogleBinged the message and learned that the configuration is something you need to do from the command prompt.

git config --global user.name yourname
git config --global user.email [email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */

# Diving Into ASP.NET 5 Beta 8? Don’t forget the web tools!

Some developers have been working closely with the evolving ASP.NET 5. Not me. I play with it once in a while. My last time was in the spring with the beta 4. Beta 8 was just released and I was working on creating a Web API. I had two projects in my solution. One was using the ASPNET5 Web API template from Visual Studio 2015.

The other used the ASP.NET 5 Class Library project template.

The Web API project had a reference to the class library project.

When I attempted to build the solution I got the following two errors that were coming from the Web API project:

CS1703  Multiple assemblies with equivalent identity have been imported: 'C:\Users\jlerm\.dnx\packages\System.Collections\4.0.10\ref\dotnet\System.Collections.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Collections.dll'. Remove one of the duplicate references.
CS1703  Multiple assemblies with equivalent identity have been imported: 'C:\Users\jlerm\.dnx\packages\System.Threading\4.0.10\ref\dotnet\System.Threading.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Threading.dll'. Remove one of the duplicate references.

I won’t bore you with everything I tried to sort this mess out. I finally did find a hack but then ran into another problem at run time — because of changes to web hosting — that was what eventually helped me find the solution to the first problem.

It turns out that the templates were my problem. There are some changes with beta 8 that resulted in the need for new project templates for Visual Studio 2015. They are contained in the ASP.NET and Web Tools 2015 (Beta 8) update for Visual Studio 2015.

# Visual Studio 2015, Command Prompt & Powershell ExecutionPolicy

Just a hint in case you run into this problem that took a few days to discover the pattern.

I have the Productivity Power Tools 2015 installed as an extension to VS2015. These are from Microsoft and there are a ton of features in there that I can’t live without.

With this I can right click on a solution or project in Solution Explorer and open a command prompt at the relevant path.

I mostly use this feature to get to posh-git to run some git commands.

posh-git is a PowerShell enhanced environment for the git command line.

There are plenty of other reasons you may want to use PowerShell interactively with Visual Studio. Working with ASPNET5 apps is a very good reason.

The problem I encountered was that occasionally, I would get into PowerShell but my Execution-Policy was, for some reason, Restricted, so I couldn’t trigger posh-git.

I finally figured out how to ensure I entered the command prompt with my normal Unrestricted ExecutionPolicy.

Be sure to open the Package Manager Console in Visual Studio first. That starts up Powershell with the correct policy. Then when you open your command prompt, you are good to go.

# Capture Screenshots Directly into Camtasia Projects

I spend a lot of time in TechSmith’s Camtasia when I’m building my Pluralsight courses. I’ve been using it for years and am a huge devotee. (disclsure that I get a free licnese as a Microsoft MVP but would willingly pay for it). often decide while editing that an image would be handy. I usually have to go grab a screenshot, save that file. Then import that file into my camtasia project and then put it into my video.

I also happen to use TechSmith’s SnagIt for my screen captures (same disclosure re free license and same but I would pay for it for sure!).

I only just discovered that there are a slew of output extensions for Snagit and one of them is Camtasia.

Here is a 30 second video (that I created in Camtasia of course) of how it works.

# Getting to posh-git in 2 Clicks from Visual Studio

Surely, many people already know this but I just  figured it out. I only just noticed the Power Commands that are part of the VS Productivity Power Tools and they led me to a cool little trick. It is a lot easier than the steps I was taking to get to posh-git in a solution’s folder.

# Problems Installing AMD Catalyst Control Center on Windows 8? Here’s my fix!

TLDR: Updating to Windows 8.1 and reinstalling solved the problem.

(And yes, I realize that I just wrote an UpWorthy-worthy post title!)

I recently replaced my 19” monitors with a pair of 27” monitors. My desktop is a Dell Optiplex and it has an AMD HD Radeon 7500 display adapter installed. This came with the Dell and is not an off-the-shelf card, but something that AMD sells generically to manufacturers.

My monitor has HDMI and DisplayPort outputs. My adapter has DisplayPort and DVI inputs. I plugged one monitor DP to DP. It was fine. For some reason, I got an HDMI to DVI adapter instead of a DisplayPort to DVI and when I plugged the second monitor in from the HDMI output, I got what is a classic problem with HDMI monitors: a 1” black border around my desktop window.

I tried many things via windows settings but none did the trick. The monitor has lots of hardware settings but it doesn’t have the classic Horizontal and Vertical scaling option that I’m used to from older monitors.

So I went to the internet and found many (many many many) recommendations on the web to just install AMD’s catalyst control center and then use it’s features to change the scaling on the monitor and lose the border.

Obviously this was the way to go. But after 4 hours of attempting to install the CCC software, I got bupkus. The installer went through the motions of installing but I did not get the CCC menu option on the desktop context menu. This is what it should look like:

I went through uninstalls, reinstalls, registry purges (based on AMD guidance), installing beta software. Still nothing.

Then I dug into the install folder created by the installer (C:\AMD) and dug through sub folders running all of the installers I could find! (Yes I know…dangerous and potential for having to repave my machine).

This finally installed a shell of the CCC though still not on my context menu. But when I ran this shell, all it had in it was a Quadrant tool that lets you define where on the screen various softare should be displayed.

I gave up on this thinking that next time I was in town, I would just get a proper DisplayPort to DVI adapter.

A month went by and I decided to try again yesterday. I only wasted 1/2 hr this time before giving up.

I also happened to decide it was time to upgrade this computer from Windows 8 to Windows 8.1. I had upgraded all of the other laptops and devices already.

After the 8.1 update was done, I decided to give CCC one last try (or at least what I was calling one last try.) I looked in the install folder and saw something I had never seen before in my many visits to that folder! A folder called WU-CCC2

In there was another install folder and in there another setup.exe!

Of course, I gave this a try and the install (because I just love to click on things!) and it did some interesting things. First it ran an uninstall (cleaning up previous garbage?) and then ran another install.

When complete, I had to reboot and the Catalyst Control Center option was finally on my menu!

I opened it up and it looked like all of the screenshots I had seen all over the internet as a recommendation on how to solve my original problem: the 1” border.

And changing the scaling on that monitor, has indeed, fixed the border problem!

Sometimes being a pit bull pays off. On the other hand, a new display adapter would have probably been more cost effective than the wasted time …but my pride was at risk, here. So I had to solve the puzzle!