# Friday, 29 January 2016


This blog has moved to www.theblomsmacode.com. Please check the new location for new content.

#    Comments [0] |
# Thursday, 17 October 2013

Windows 8.1 available for download

Windows 8.1 is available for download and great news! It is free to anyone already running Windows 8.

Download available here: http://blogs.windows.com/windows/b/bloggingwindows/archive/2013/10/17/windows-8-1-now-available.aspx

#    Comments [0] |
# Thursday, 27 June 2013

Visual Studio 2013 Preview available for download

Interested in test driving the next version of Visual Studio? Download the Visual Studio 2013 Preview at: http://www.microsoft.com/visualstudio/eng/2013-downloads

#    Comments [0] |
# Thursday, 06 June 2013

NuGet 2.5.4

NuGet 2.5.4 has been released. With over 160 work items in this release the team felt they should skip version numbers 2.3 and 2.4. Checkout the release notes at http://docs.nuget.org/docs/release-notes/nuget-2.5.

#    Comments [0] |
# Monday, 25 February 2013

NuGet 2.2.1

NuGet 2.2.1 was released on February 15, 2013. The VS Extension version number is 2.2.40116.9051.

This release/update fixes 5 bugs. Here is a link to the issues fixed: http://nuget.codeplex.com/workitem/list/advanced?keyword=&status=Closed&type=All&priority=All&release=NuGet%202.2.1&assignedTo=All&component=All&sortField=LastUpdatedDate&sortDirection=Descending&page=0

It is sometimes hard to find release notes on these updates, so here is a link.

Link: http://docs.nuget.org/docs/release-notes/nuget-2.2.1

#    Comments [0] |

Productivity Power Tools 2012 – February 2012

A new update to Productivity Power Tools 2012! This update includes a couple of bug fixes including a crashing bug in the Custom Document Tab Well on debug. Download now!

Link: http://visualstudiogallery.msdn.microsoft.com/3a96a4dc-ba9c-4589-92c5-640e07332afd?SRC=VSIDE 
Download: ProPowerTools.vsix

#    Comments [0] |
# Saturday, 16 February 2013

Upcoming Events

Here are some events in which I’m involved or which are being organized by friends:

February 25, Maine Developer Network (Augusta, Maine): Two topics in this meeting: First What’s New in Entity Framework 5 and second Using NuGet and creating packages. More on: http://www.maine-devnet.org/Home/Meetings.aspx

February 26, Bangor Area .NET Developer (Bangor, Maine): Two topics in this meeting. First Windows Azure and second How to get free/cheap Microsoft software. More on: http://www.bangordevelopers.com/

March 18, SDN Event (Zeist, The Netherlands): A bunch of topics ranging from Delphi for iOS to Windows Azure to SOLID principles. More on: http://www.sdn.nl/SDN/SDNEvent/Events2013/SDNEventMaart2013/tabid/219/Default.aspx

#    Comments [0] |
# Tuesday, 12 February 2013

Deleting a project from Team Foundation Service

I ran into this today. We needed to delete a project from Team Foundation Service, but there is no way to do this through the UI. Luckily Buck Hodges wrote a post on this already. You need to use the command line TFSDestroyProject.exe tool and make sure to use the VS2012 version, not the VS2010. Also include ‘DefaultCollection’ when specifying the collection name.

Read more here: http://blogs.msdn.com/b/buckh/archive/2011/09/19/how-to-delete-a-team-project-from-tfs-on-azure.aspx

#    Comments [0] |
# Tuesday, 29 January 2013

Creating ASP.NET membership and authentication tables in SQL Server (Aspnet_regsql.exe)

There is a little command line tool that can create the standard ASP.NET membership and authentication tables in an existing SQL Server database instance. (Since I seem to have a hard time remembering the name of the tool I’d figure I’d write a little blurp on my blog to act as a reminder Smile ).

Aspnet_regsql.exe is a command line tool. You can run it without parameters to have it help you in via wizard mode, or apply the right parameters and do it commando-style. See http://msdn.microsoft.com/en-us/library/ms229862.aspx for available parameters.

And if you want to enable the ASP.NET Web Administration Tool on a test or production server, then this forum post http://forums.asp.net/t/932674.aspx/1 tells you how to do that.

#    Comments [1] |
# Wednesday, 23 January 2013

Speaking at Augusta Tech Talk

The invitations just went out: I’ll be presenting at Augusta Tech Talk on February 25th 2013. There will be 2 sessions; one about NuGet and one about Entity Framework 5.

For more information and registration got to: http://maine-devnet.org/Home/Meetings.aspx

#    Comments [1] |
# Monday, 21 January 2013

NuGet, Files and Source Control

I’ve been using NuGet for years, but recently I’ve been playing with around with NuGet to try and explore some of the lesser known features. I’ve just been using NuGet to effortlessly download and add assemblies to my projects, but where do these files go? And how do I make sure that when I zip my sources and send them to another developer, that person also has everything he needs? How does NuGet play with regards to source control?

Default NuGet Workflow

The default process when using NuGet to install a library (for example EntityFramework) in your project is as follows:

  1. Start a new project in a new solution and add the solution to source control.
  2. Open the Package Manager Console.
  3. Type: “install-package EntityFramework”
  4. At solution level NuGet creates a folder named ‘Packages’.
  5. NuGet determines the most recently, non-beta, available version of EntityFramework and downloads this file into a folder, named after your package in the ‘Packages’ folder. It also creates a ‘repositories.config’ file to keep track of which projects are using NuGet. The folder may look something like this: 


    Note that all the files in the ‘Packages’ folder and it’s subfolders are automatically added to source control.
  6. NuGet adds a packages.config file to your project and uses this to keep track of which packages and versions are installed in the project:

  7. When you now check into source control all configuration information as well as all the downloaded packages are preserved and managed in source control.

The default approach works well in most scenarios, but has one downside: if you have a lot packages in your solution, then the size of your source control branch may become larger than desired. This would be less of an issue with say Team Foundation Server, but more of an issue with a DVCS like Mercurial or Git.

Restore During Build Workflow

An alternative approach is offered by using the Enabling Package Restore During Build option. Read the tutorial here to see how it is done.
There are three differences with the default NuGet workflow:

  1. A .nuget folder is added to the solution, which contains NuGet.exe, a config file and a build file. These file will be added to source control upon check in.
  2. Downloaded NuGet packages in the ‘Packages’ folder (they’re still there) are not added to source control.
  3. Every time you (re)build your project the NuGet build step will check to make sure the appropriate NuGet packages have been downloaded.

Zipping projects

As a rule: whenever you want send someone the sources of a project that uses NuGet for maintaining library references, make sure you send the solution, including the packages folder. If you’re using the Restore During Build Workflow, then the zip does not need to contain the actual packages.

#    Comments [0] |
# Tuesday, 27 November 2012

Visual Studio 2012 Update 1 is available

Microsoft has just made good on its promise of frequent updates to Visual Studio. The first update for Visual Studio 2012 is now available for download.

Somegar has done a nice blog describing the new features in this update: http://blogs.msdn.com/b/somasegar/archive/2012/11/26/visual-studio-2012-update-1-now-available.aspx

Or jump straight to the download at: http://www.microsoft.com/visualstudio/eng/downloads#d-visual-studio-2012-update

#    Comments [0] |
# Sunday, 02 September 2012

Entity Framework 5 + Enumerations => What’s not to love?

Entity Framework 5 now supports enumerations (when using Visual Studio 2012 and targeting the .NET 4.5 framework).

So let’s have a look. We’ll create a table called Planet with a name and a field to indicate whether it is habitable.

CREATE TABLE [dbo].[Planets](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](max) NOT NULL,
    [Habitable] [smallint] NOT NULL,
    [Id] ASC

Note: the data type for ‘Habitable’ is a smallint.

Next we’ll generate an entity data model from the database. Nothing exciting, since our database has just one table.


When we inspect the properties of the ‘Habitable’ property we see that, as expected, it is mapped to an Int16 (short).


Instead of a short we want to map the field to the following enumeration (note that having the enumeration be of type ‘short’ is significant, the type you select for your enum needs to match the column type in the database):

public enum HabitableEnum : short
  Humanoids = 1,
  Insects = 2,
  Droids = 3,
  None = 4,
  All = 5

In order to so, we need to update the model with information about the enum. This is done in the Model Browser.


Look for the “Enum Types” node and right click to add an Enum to the conceptual model.


We can have a locally defined enumeration (to be used in the T4 code generation) or we can refer to the previously defined enumeration by checking the “Reference external type” checkbox.

After adding the enumeration to the model we can now go and update the “Habitable” property in the conceptual model, the enumeration will now be displayed in the type listbox.


If we now browse through the generated code (click the triangle next to the Edmx file in your solution explorer) you’ll see that the generated class for “Planet” is now using the enumeration.

public partial class Planet
    public int Id { get; set; }
    public string Name { get; set; }
    public EF5Demo.Xyz.HabitableEnum Habitable { get; set; }
Should you not see the change, then right click on <yourmodelname>.tt and choose “Run Custom Tool” in order for the T4 template to regenerate the classes.

We can now write some code to insert and query the database. Here is an example:

var ctx = new StarWarsEntities();
Planet p1 = new Planet() { Name = "Tatooine", Habitable = HabitableEnum.Droids };
Planet p2 = new Planet() { Name = "Coruscant", Habitable = HabitableEnum.Humanoids };
ctx.Planets.Add( p1 );
ctx.Planets.Add( p2 );
var query = from p in ctx.Planets
            where p.Habitable == HabitableEnum.Humanoids
            select p;
foreach ( var p in query )
  Console.WriteLine( p.Name + " - " + p.Habitable );

When we run it:


That’s all there’s to it. Using enumerations with Entity Framework 5.

But wait, would it not be nice if we could use byte based enumerations and assign multiple values of the HabitableEnum to a planet?

Lets modify the enumeration to use the Flags attribute:

public enum HabitableEnum : byte
  Humanoids = 0x1,
  Insects = 0x2,
  Droids = 0x4,
  None = 0x8

We need to change the type of the ‘Habitable’ column in the database to a tinyint and we need to modify the information in the conceptual schema to inform the entity framework of our change in design:


The screenshot shows that we need to change the underlying type as well as check the “Set Flags attribute”.

We can now write code that assigns multiple values to the habitable field:

using ( var ctx = new StarWarsEntities() )
HabitableEnum x = HabitableEnum.Humanoids;
x |= HabitableEnum.Insects;
Planet p1 = new Planet() { Name = "Tatooine", Habitable = HabitableEnum.Droids };
Planet p2 = new Planet() { Name = "Coruscant", Habitable = x };
ctx.Planets.Add( p1 );
ctx.Planets.Add( p2 );
var query = from p in ctx.Planets
            select p;
foreach ( var p in query )
  Console.WriteLine( p.Name + " - " + p.Habitable );

The output looks like this:


If you wish to query for just insects you need to write a bitwise AND statement, like:

var query = from p in ctx.Planets
            where ( p.Habitable & HabitableEnum.Insects ) == HabitableEnum.Insects
            select p;

That’s all folks, have fun!

#    Comments [2] |
# Sunday, 26 August 2012

Entity Framework 5 is available

Entity Framework 5 is included in Visual Studio 2012, but is also available to users of Visual Studio 2010 (as a NuGet package: http://nuget.org/packages/EntityFramework/ ).

Note: Some Entity Framework 5 features are only available when writing an application that targets .NET 4.5. This includes enum support, spatial data types, table-valued functions and the performance improvements.

Read more about what is new on the MSDN ADO.NET blog: http://blogs.msdn.com/b/adonet/archive/2012/08/15/ef5-released.aspx

Update [08-27-2012] : Julie Lerman has an excellent post describing the difference between running EF5 in a .NET 4 versus a .NET 4.5 application, read more on: http://thedatafarm.com/blog/data-access/when-entity-framework-5-ef5-is-not-entity-framework-5-ef5/

#    Comments [1] |
# Thursday, 16 August 2012

Windows 8 RTM and Visual Studio 2012 now on MSDN

For those of us with an MSDN subscription: Windows 8 RTM and Visual Studio 2012 are both available for download. Go to https://msdn.microsoft.com/en-us/subscriptions to get your copy.



#    Comments [2] |
# Monday, 30 April 2012

String literals and ‘==’ versus Equals(…)

I had a little fun today playing with ‘==’ vs. the Equals(…) method. I knew that somewhere in .NET 2.0 (I believe) there had been some improvements in String.Empty versus “”, but I didn’t quite realize that this affected all string literals.

In the code below you can see how value types and reference types may behave differently when using ‘==’ versus the Equals method.
My surprise came when I discovered that line 39 and 41 both return TRUE. Apparently the string literals in an assembly get put in a master list of string constants and then reused where the same string literal gets used. Nice!
The way to force the reference comparison of the string against object to actually be different is to delay the creation of the string until runtime, like in line 52.

   1:  static void Main(string[] args)
   2:  {
   4:      // value types
   6:      int x = 10;
   8:      int y = 10;
  10:      Console.WriteLine( x == y );  // compare by value -> return true
  12:      Console.WriteLine( x.Equals( y ) ); // compare by value -> return true
  14:      Console.WriteLine( object.ReferenceEquals( x, y ) );  // compare by reference -> return false
  17:      Console.ReadLine();
  19:      // Reference types
  21:      StringBuilder s1 = new StringBuilder( "yes" );
  23:      StringBuilder s2 = new StringBuilder( "yes" );
  25:      Console.WriteLine( s1 == s2 ); // compare by reference -> return false
  27:      Console.WriteLine( s1.Equals( s2 ) ); // compare by value -> return true
  29:      Console.WriteLine( object.ReferenceEquals( s1, s2 ) ); // compare by reference -> return false
  31:      Console.ReadLine();
  33:      // object and string
  35:      object o1 = GetName();
  37:      string o2 = "Mark";
  39:      Console.WriteLine( o1 == o2 );  // compare by reference -> return true
  41:      Console.WriteLine( o1.Equals( o2 ) ); // compare by value -> return true
  43:      Console.WriteLine( object.ReferenceEquals( o1, o2 ) ); // compare by reference -> return true
  45:      Console.ReadLine();
  48:      // object and string
  50:      object ss1 = "Mark";
  52:      string ss2 = "Markx".Substring( 0, 4 );
  54:      Console.WriteLine( ss1 == ss2 );  // compare by reference -> return false
  56:      Console.WriteLine( ss1.Equals( ss2 ) ); // compare by value -> return true
  58:      Console.WriteLine( object.ReferenceEquals( ss1, ss2 ) ); // compare by reference -> return false
  60:      Console.ReadLine();
  61:  }
  63:  static object GetName()
  64:  {
  65:      return "Mark";
  66:  }
#    Comments [4] |
# Wednesday, 29 February 2012

Windows 8 Consumer Preview

ISO images with the Windows 8 Consumer Preview are now available for download. Go to http://windows.microsoft.com/en-US/windows-8/iso to get the bits.

#    Comments [3] |

Microsoft Visual Studio 11 Ultimate Beta

Microsoft Visual Studio 11 Ultimate Beta has just become available for download. Go to http://www.microsoft.com/download/en/details.aspx?id=28975 to download the bits.

#    Comments [0] |
# Tuesday, 24 January 2012

Type-Safe Include extension method for Entity Framework

If you’re interested in the Include method in a LINQ to Entities queries to be type-safe, then Joe Ferner has the answer for you in this post: Type-Safe Entity Framework Include: http://www.nearinfinity.com/blogs/joe_ferner/type-safe_entity_framework_inc.html

#    Comments [0] |