Connecting SQL Operations Studio to SQL Express server in Parallels VM

In this post, I’m going to show how to marry SQL Operations Studio running on macOS with MS SQL Express running on Windows VM in Parallels.

Even though SQL Ops Studio is not a fully mature project it’s already sufficient enough to perform simple and quick actions.


Since I’m running most of the apps on a host macOS and I’m trying to keep my windows VM as lean and possible, I think SQL Ops Studio is a good choice for most of my SQL related tasks. I still have to keep MS SQL Management Studio installed because I’m using RedGate tools such as SQL Source Control, but that’s a different story.

My system overview

First of all, let’s check what I’ve got installed here:

  • MacOS host system. Running macOS High Sierra 10.13.2
  • Parallels Desktop 13 Pro
  • MS Windows 10 Pro Virtual Machine
  • SQL Operations Studio 0.24.1
  • SQL Express Server 2014

Windows VM is configured to have a static IP address.

Set up SQL Express to accept incoming connections

To set up SQL Express we need SQL Server Configuration Manager.

I’m running SQL Express 2014 so need to type SQLServerManager12.msc.

Starting SQL Server Network Configuration Manager

Go to SQL Server Network Configuration -> Protocols for SQLEXPRESS -> TCP/IP

SQL Server Network Configuration screenshot

Right click and select Enable:

Enable TCP/IP protocol

Set up port number as on the picture (you’re free to use any value, I’m using 5171 here)

Set up tcp/ip port

Configure Windows Firewall

We must allow sqlserver.exe to accept inbound connections:

Windows Firewall, create new rule


By this time you should be ready to connect to the SQL Server.

Connection string should look like this one:

tcp:<your-vm-ip>,5171, database-name

In case your SQL EXPRESS instance is set up to use Windows Authentication most probably you would see an error like that:

Kerberos Error message

There is a good article with step-by-step instructions. Please refer to it.

You can always switch to Mixed Authentication Mode :)

That’s all folks!


You are mocking it wrong.

Well, probably you are not, but let me grumble a little bit anyway.

Mockingbird picture Mockingbird knows how to mock.

I’ve been working with various code bases throughout of my career, and there is one pattern which I see rather often. As you may have already guessed it’s the unit-tests and mocking I’m going to talk about here. To give it a nice catchy start, I’d claim here, that mocks should be used when you have to, but not when you can.

I’ll give a few examples of somewhat useless and even harmful tests.
All the examples are going to be made up, but I hope you’d get the point.

So, let’s start with the typical Greeter example. This is a “Hello, world” of Unit Testing. In one way or another, this sample gets repeated in all the articles, posts and books dedicated to unit-tests and mocking frameworks.

   string Greet(string name, string title);

public class Greeter: IGreeter{
  public string Greet(string name, string title){
    return "Hello," + title + " " + name;

public class Client{
  private IGreeter _greeter;
  public Client(IGreeter greeter){
    _greeter = greeter;
  public string FormatPageHeader(string name, string title){
    return "<h>" +  _greeter(name, title) + "</h>";

 public class ClientTests {
    pubic void Test(){
        var mock = new Mock<IGreeter>();
        mock.Setup(greeter => greeter.Greet("John", "Mr.")).Returns("Hello, Mr. John");
        var result = new Client(mock.Object).FormatPageHeader("John", "Mr.");
        Assert.AreEquals(result, "<h>Hello, Mr. John</h>"); //All good here, what does it test, tho?

So far so good. Tests are green. The Greeter interface isn’t perfect, though. Two strings as a parameter? So easy to mess up, isn’t it? Most probably you have a method like that in your project.

Ok then, imagine that you decided to make this method less error prone. You don’t have much time for a proper refactoring because you have a feature to work on. Let’s just swap the parameters. It’s much more natural for a human to put the title before the name. Depends on the culture, I know.

(“John”, “Mr.”) is more awkward compared to (“Mr.”, “John”) and (“Dr.”, “Smith”).

So, we’ll end up with the greeter like that:

//Version 2
public class Greeter2 : IGreeter{
  public string Greet(string title, string name){
    return "Hello, " + title + " " + name;

   string Greet(string title, string name);

add., commit, push. Our beloved build server will pick the changes up, will run the tests and will fail of course. We forgot to update the test for the IGreeter implementation. Once they fixed we’re good, aren’t we?

Not really, remember the Client class? Now it’s incorrect, we still pass the title and the name in the old order, even though our test claims that everything is fine.

This is fine

Here is the paradox, we introduced mocking so that we can test our class in isolation, but we had to put some code to make that mock return something. It’s still the logic, isn’t it? Now IGreeter has at least two implementations. Most probably in your codebase, you have tens of implementations for the mocked class. Just because it’s a very much reused dependency, and you have to mock it all over again.

We can improve that test, tune it, but the only way we can make it fail is to repeat the Greeter logic in our mock set up. But wait a minute, if we have the same implementation, why don’t we reuse the existing code?

The more complex your mocked object is the more complex your mock setup becomes. If that’s not the case, most probably you’re testing just the interaction with your dumb mock, i.e. you’re not testing anything. Just like the ClientTest above. The only positive outcome is the extra 20c which your company pays to Amazon for that CPU time you waisted on the build server.

It’s not rare to have more than one dependency. I can imagine that our Client could use some IHmlRenderer which would consume the IGreeter result. You would mock that one too, right?

Sweet as. You now have a test which verifies how two mocks are integrated with each other. How does that prove your code correctness, thought? I don’t know.

I’m going to step back now, and talk about it from another point of view. What does the typical system look like? I assume, it’s not the bunch of isolated classes, but it’s more like a spiderweb of dependencies. If you look at type dependency diagram you would see a group of clusters, where each cluster is a somewhat tightly coupled set of classes. This is how we manage complexity, we break down one large class into small pieces, but those pieces would never be used in isolation. Each of them would be responsible for a little piece of work. You would write a separate test suite for them, mock out all the dependencies (they all belong to the same cluster).

How is that different to the attempt to test a private method?

That little convenience wrapper for the standard library class is nothing more than an implementation detail.

But integration tests are slow…

That would be an expected note. If we come back to our ClientTest. What performs better, the test with mock, or the test with the concrete Greeter implementation? I guess the answer is obvious. We shouldn’t forget that that test doesn’t prove anything. It is slower, it allocates more, and it’s wrong. I’d say it’s harmful.

So you’re going to send out those emails every time you test?

Ok, that is a good question. Remember I said that we should mock when we have to, not when we can? That’s exactly the right situation for the test isolation.

You don’t want to make HTTP calls while running your unit tests suite, you don’t want to send out emails, neither do I.

Hey, I tried not to mock, and I got sick of initing all the dependencies

This is where it gets painful. I saw systems like that, it’s a nightmare to maintain. Manually setting up the dependency of the dependency is really not the way to go. It’s hard, and everyone would avoid writing a new test. But that’s an easy task to solve.

How do we build a dependency tree in the runtime? I hope you’re using the DI framework which wires up interfaces and implementations together, it knows how to create a new dependency, it knows when and how to rebuild a dependency tree. If you’re building a web service you should reset the state between requests, so keep as many dependencies request scoped as it’s possible.

The same pattern is applicable for your test suite. Everything is request scoped and stateless already, so treat each test as a ‘request’ and let the DI container to build the system under test for you.

Of course, you would have to set up the DI container differently.

Module (or cluster) level test would build the dependency tree for that module but would mock out the rest of the world. Like no HTTP calls, no DB, no emails, you’ve got the point.

At this point, you would realize that you don’t need that test which verifies that your utility class can split the string, but you would be sure that your MortgageCalculator does the job. After all, that is your business rule, and that is the feature you’re building. Unless you are the low-level framework developer of course. Most of us are not, though.

Once you’ve got all the clusters well tested, all the interfaces established you may try to break it down a little bit. Or you may want to leave it as is, it’s up to you.

Imagine you want to extract some logic into the separate class. Now your system has a new dependency, but that logic has already been tested. You don’t need to set up a new mock, you don’t need to repeat the logic of the extracted class in your test set up, you don’t need to update the test to instantiate the tested class. It’s just there, and your safety net still works. If you extract and modify the logic, you would break the test. Do you see the beauty? Extracting the class and introducing a new dependency is as easy as moving the logic into a private method.


The approach above would give you the following benefits:

  • Fewer meaningful, useless and harmful tests
  • No need to maintain duplicated implementation (mock set ups)
  • Feature driven tests, tests that verify that the cluster does the job
  • An easy to refactor code base
  • You can improve module level access (no need to make the class public just for the testing)

From my experience tests, based on that cluster approach, are much more reliable. When they break, they actually mean that the system is dysfunctional, when they pass you can be sure that you did not break the logic.

We still have to run integration tests to be sure that the third party integrations are working, that the system’s runtime configuration is valid.

I am more than open to any criticism, feel free to tear that post apart.

Investigating unexpected MSBuild behavior

Recently I took latest changes from git, merged dev to my current branch and decided to run few integration tests. You know, just to be sure.

What do I see? well… this.

Could not load file or assembly ‘Microsoft.Data.Edm, Version=, Culture=neutral, PublicKeyToken=... or one of its dependencies.

That doesn’t sound right, though it’s typically easy to fix.

The first reaction is to consolidate NuGet packages in my Solution. All the installed packages have same version 5.7.0 though.

Package.config sample

Well, that happens when a merge conflict was poorly resolved. Perhaps one of the project files has a reference to an old version.

Full-text search shows that each .csproj file has correct path in the <Reference> tag.

Curiouser and curiouser!

dotPeek confirmed that the Microsoft.Data.Edm.dll version in the \bin folder is indeed incorrect. That’s odd because I don’t have an old version anywhere close to my solution. So where does it come from?

Reading raw MSBuild logs is some kind of an art, so this is where MSBuildStructuredLog comes to the rescue.

Make sure to add it to your toolbelt! This is a very handy tool for MSBuild logs analysis.

Let’s run a verbose build and look at the log. The log is very detailed, however, I think that DoubleWrites section a good starting point.

And here we go: Microsoft.Data.Edm is initially taken from local packages folder and after that suddenly overwritten by the wrong version from my .NETFramework folder.

MSBuild log

Still not clear why.

Luckily we can search through the logs. We’re interested in resolve messages here:

Resolved file path is "C:\Program Files (x86)\Microsoft WCF Data Services\


This is our “Ahaaa” moment! As you can see on a screenshot above while building project 1 (see the red number, eh?) ResolveAssemblyReferences target picks up a wrong version of that DLL which is required by project 2.

Project 1 has a reference to project 2, and indeed has no references to Microsoft.Data.Edm dll.

VS Project References

And now it’s somewhat clear what’s going on. On the screenshot below we can see a part of the build log, where unimportant log entries were omitted. First occurrences of project 1 and project 2 are marked on the screenshot.

MSbuild log. Overview

It seems that MSBuild failed to resolve a path to Microsoft.Data.Edm while preparing project 2, and that’s why an old version was used for project 1. However, project 2 has all the references configured correctly. Once the incorrect DLL version was resolved it’s being used for all remain projects.

I’m not sure if that’s an expected behavior. To be honest I’m a bit confused here. At least as a temporary solution I can add Edm package to project 1. That will fix my problem for now.

Write code for the reviewer, not for the compiler


I’ve been doing code reviews on a daily basis for several years for now. This activity is very different from what I do as a developer.

Most of the time I try to understand, debug, fix or update existing code. Less often developers write new code from scratch. I think it’s safe to say that we all know how to work with a code written by another human.

One might want to say that if we know how to work with other people’s code, we can be good at reading and understanding it during the code review process.

Unfortunately, there is a difference. When we work with a code we have it opened in our editor or IDE. It doesn’t matter if it’s a modern heavy IDE or a lightweight editor. What’s important is that this is a tool which we are familiar with.

We know how to get extra information about any line code on the screen. In my case, it’s a Visual Studio with ReSharper and several more extensions. I have color coded info, I have tooltips and I can navigate through the code.

However, when reviewing a Pull Request on GitHub I have just a basic syntax highlighting in the editor.

Pull Request sample


Modern programming languages allow a developer to skip some symbols and take some shortcuts. It’s different for every language, I’ll use C# as an example in this post.

Let’s look at this snippet:

public void ProcessSomething(Guid accountId)
  AccountBalance accountBalance = 
        .GetAccountBalanceAsAtDate<Guid>(accountId: accountId, date: this.DateUtils.Yesterday);

Here we have a short method implementation. C# keywords are in blue-ish color, method names are in magenta, the rest is gray.

Even if you don’t know C# you can read and understand what’s going on there.

If you do know C# you’d notice that this code is rather redundant. However, this is pretty much how compiler sees your code. Ok, almost :)

Let me read this code. I’ll try to read all the information which I see here.

This method takes an account id (GUID). First it calls the GetAccountBalanceAsAtDate generic method with Guid generic parameter. This method is an instance method of field balanceCalculator. This is a current class instance field.
There are two parameters passed to that method. The first one is an account id, the parameter name is accountId. The second parameter name is date, and we pass the value of the property called Yesterday of the current class instance property called DateUtils.

The result is assigned to the local variable accountBalance of AccountBalance type. After that the result is passed to the instance method CalculateFees.

That’s a lot of information, right? We know types, parameter names, we know that methods and properties are not static and so on.

We still don’t know what type Yesterday is, but the rest is clear. We have plenty of information about the logic of the method as well as about types and even some details about GetAccountBalanceAsAtDate method signature.

Getting simpler

When I look at this code in my IDE I see that some code is marked as redundant (grayed out):

Same Code in IDE

What if I apply suggested “Remove redundant code” refactorings? We’d loose some information about this method. I’m going to be careful here.

Argument names

Explicit argument names here are probably the least important information. Even more, it’s a bit misleading. Are the arguments optional or not? We don’t know that. (Well, I do know, and they are not optional).

Let’s remove them:

Code in IDE, argument names omitted

I’m going to repeat our exercise one more time:

This method takes an account id (GUID). First it calls the GetAccountBalanceAsAtDate generic method with Guid generic parameter. This method is an instance method of field balanceCalculator. This is a current class instance field.
There are two parameters passed to that method. The first one is an account id, and as a second parameter we pass the value of the property called Yesterday of the current class instance property called DateUtils.

The result is assigned to the local variable accountBalance of AccountBalance type. After that the result is passed to the instance method CalculateFees.

Hm, looks like we didn’t lose much information, right?

Explicit variable type

When reviewing this snippet we don’t know much about AccountBalance type. Is it a struct or a class? What kind of data does it contain?

In fact, we can just omit the type declaration here.

Code in IDE, use var instead of Explicit type

So far so good. We don’t know the type, but we do know that the type is correct. We were able to pass it to CalculateFees method, and our code compiles.

Generic parameter type

What kind of information could the reviewer gather from the explicit generic parameter type specification?

Honestly, I don’t know. Perhaps we can figure out that the method is generic. Well, good to know, but as long as the compiler can build the code, it doesn’t matter for the reviewer.

After all the reviewer is not trying to catch compilation errors, eh?

Code in IDE, implicit generic parameter type

this qualifier

This is a very painful moment.

There is a StyleCope rule SA1101: PrefixLocalCallsWithThis which originally aimed against underscore prefixes for instance variables.

First of, all we should understand, that the compiler does know that CalculateFees() is an instance method of the current class. It does know where DateUtils comes from.

Honestly, how often do you need to know if balanceCalculator is an instance variable? That might be important when you editing the code. Not very often, but I can buy this argument.

But is that important during the code review? I’d say that it’s not. Id doesn’t matter for this method. The method is short enough so we can see that balanceCalculator is not declared inside the method. If the method was longer, it would not be important anyway. What’s important is that the balanceCalculator was used to calculate the balance.

Nobody would argue that the code outside of the editor contains less information about its structure. The absence of this knowledge is not that bad, though.

For example, When reviewing the code outside of the editor no one can tell what’s going on here:


Each *.Car could be either a property of current class instance property or a static property of another class or an enum value. this. qualifier will help us with the first option, but that’s it.

In your IDE you’ll spend a second to find out, right? I’ll use color codes:

Code in IDE, no redundant code

You can hover or navigate to it. Doesn’t really matter.

When you read this code as a plain text you can only tell that the method Foo is doing something with the car. You have lost some information, and you only have a semantics of the code here.

And this is just fine. You can focus on what the code does, not on how it does. The “how” part is checked by the compiler.

It requires some courage, but I’m going to remove all this. prefixes.

Final look

Code in IDE, no redundant code

So, what do we have here? As we learned, as a reviewer we need to focus on the logic, and we shouldn’t try to chase any errors which can be caught by the compiler.

Let’s read it one more time:

The method takes and account Id as an argument, calls GetAccountBalanceAsAtDate method of the balanceCalculator. accounId is passed as a first parameter, the second parameter is a value Yesterday of DateUtils. The result of that method call is used as a parameter for CalculateFees method.

Now scroll up and compare with the first attempt. Much shorter, right?

Ok, the reviewer has no information about types, about the nature of methods and properties. They do not know what DayUtils is. It might be an enum, or a static class or anything else.

The only information that reviewer has is the logic of the method. And now they can focus on it because that’s what is important here after all. The logic, not the AST structure.


Please, let the compiler to its job, and help the reviewer focus on what does matter here.

Feel free to comment on this if you agree or disagree.

Dev environment 2016. Windows.


I’ve changed a job last month and had to build up my dev environment from scratch again. While doing that I decided to write down some thoughts about it.

I guess it might be interesting to look back at some point and see how does it evolve.


At my previous employer, we were very into Virtual Machines. We had different base VMs which every developer can download.

That’s extremely handy when a new hire has nothing to do, but to install just a couple of tools that are not standard, and enter some credentials.

You remember those dialogs:

— I can’t build the project. Packages are missing…

— Oh, yep, you need to add this private NuGet feed.

— I can’t run the project locally.

— Yeah, I think you need so put these lines into your hosts file.

Well, now it’s all gone.

It’s not only limited to this scenario. You want to experiment with a new unstable version of the framework (yes, .NET Core RC-final-almost-stable, I’m talking about you) and you don’t want to mess up with your dev machine?

Just fire a new VM up.

Got a neat idea for a hackathon, but you think that JDK is not what you need on your computer? Giving a tech demo on the local meetup?

A VM comes to the rescue.

Got a new computer? Just copy the VM over and you’re up to speed in 20 minutes.

Back to the topic

So, what do I have on my base VM?


I’m a .NET web developer, so nothing special here:

  • .NET framework 4.5.2 and 4.6
  • Node.js (npm, gulp)

IDE and editors


File Managers and command line shell


Source control


GitKraken is quite heavy and not super fast as most of the electron.js based tools are, but I find it’s history tree view very readable. The merge tool is not bad at all.

I do most of the git related operations in git bash, though.

Debugging and profiling


  • DotPeek. A free .NET decompiler.
  • DotMemory .NET memory profiler.
  • WinDbg.
  • Fiddler. A free web debugging proxy.
  • REST and Http clients. I use two, can’t decide which one I prefer over an other.
  • LINQPad A .NET programmer’s playground.


  • Slack
  • Skype

Other tools

Web tools and services

Besides all the tools above which I have installed locally there are web services I use on a pretty much daily basis.

  • An easy to use HTTP request inspector.
  • AppVeyor. A free CI/CD service for my open source projects.
  • A super awesome regular expressions builder and debugger.
  • Toggl. A time tracker.

Batch install

Most of the tools could be installed from Chocolatey gallery.

choco install dotnet4.5.2 linqpad -y

I prefer to have all the tools grouped into .config files:

<!-- commandline-tools.config -->
<?xml version="1.0" encoding="utf-8"?>
  <package id="git" />
  <package id="far" />
  <package id="nuget.commandline" />
  <package id="conemu" />

and they could be installed all together.


A call to action

Are there any tools around which are worth to try?

Please share in comments. I’m always keen on trying new things.