Breeze, Require, and Knockout

If you load Breeze using Require and AMD, AMD looks for a module named ko

As is recommended best practice, knockout registers with require anonymously (i.e. using the filename as the module name).

So if your knockout file is knockout.js and you try to load Breeze via AMD, Breeze wont be able to find knockout.

The two options are,

Rename knockout.js to ko.js

Include the following map in your Require config,

psake, .NET 4.5.2 and MSBuild

At the time of writing (December 2014), the latest version of psake (4.4) defaults to the .NET framework 4 if you don’t explicitly set a framework at the top of your build scripts.

Due to the the peculiar way Microsoft setup MSBuild for .net 4.5.x, this means that psake fails with the following error if you try to build a solution that targets 4.5.1 or 4.5.2.

You have to explicitly set the ‘Framework’ variable to 4.5.1 at the top of the file to make psake use the correct version of msbuild.

Note that using the value 4.5.1 also works for projects that target 4.5.2 (the value 4.5.2 is not recognised by psake).

How to view EntityValidationErrors in Visual Studio

If Entity Framework throws a validation exception when saving, Visual Studio reports the message,

Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details.

But the in-built ‘View Detail’ dialog doesn’t let you drill into the EntityValidationErrors property.

To view the EntityValidationErrors collection, add the following Watch expression to the Watch window.

Which displays a similar to,
Capture

The watch expression ‘$exception’ displays any exception thrown in the current context, even if it has not been caught and assigned to a variable.

SQL Server date formats

There are only two unambiguous SQL Server date format strings guaranteed to work in all versions SQL Server,

yyyy-MM-ddTHH24:mi:ss

and

yyyyMMdd HH24:mi:ss

That is all.