Scope

This article has the goal to show how to update a .NET back end project from Azure Mobile Services, this means we will update the project references using Nuget packages.

Introduction

Microsoft Azure Mobile Services is an Azure service offering designed to make it easy to create highly-functional mobile apps using Azure. Mobile Services brings together a set of Azure services that enable back end capabilities for your apps.

When a developer creates a .NET back end project from Azure Mobile Services, several NuGet packages will be installed, for example, if the project is created in Visual Studio 2013 - Update 4, like we can see in the Image 1:

Image 1 Creating the Azure Mobile Service

The default package files will be like as follows:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="3.5.2" targetFramework="net45" />
  <package id="AutoMapper" version="3.2.1" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.ActiveDirectory" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Jwt" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="RazorEngine" version="3.4.1" targetFramework="net45" />
  <package id="System.IdentityModel.Tokens.Jwt" version="3.0.2" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.2" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend" version="1.0.405" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Entity" version="1.0.405" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Tables" version="1.0.405" targetFramework="net45" />
  <package id="WindowsAzure.ServiceBus" version="2.3.4.0" targetFramework="net45" />
</packages>

But if we "Manage NuGet Packages" and select "Updates", the windows will show that there are updates that we can do like we can see in the Image 2:

Image 2 Manage NuGet Packages - Available Updates

the first thing we can try to do is to click in the "Update All" button, that will make sense for the developers, but then we will get something as we can see in the Image 3:

Image 3 Error updating all

And you have a world of nightmares.  Updating the NuGet packages from Azure Mobile Services start adds 36 NuGet packages to the project and is extremely challenging to understand the dependencies between the different NuGet packages.  If we start updating one by one we will get errors as in Image 4 below.  It is not practical to update this one by one - this article shows how to avoid the problem.

Image 4 Azure Mobile Service with errors

It means the reference added to the project is not the same version used by any NuGet and can be hard to understand which is the right version.

Description

To understand the NuGet packages and because our project is an Azure Mobile Service project, we can start by analyzing the packages.

In the NuGet website, we found.

Microsoft Azure Mobile Services .NET back end 1.0.405

Has the dependencies:

Has the dependencies:

Has the dependencies:

This way, we can conclude the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension 1.0.405 NuGet depends on the WindowsAzure.MobileServices.Backend.Tables NuGet and this depend on the WindowsAzure.MobileServices.Backend NuGet. This mean if we update the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension NuGet the references related with Azure Mobile Service will be updated.

In the "Manage NuGet Package" click on update the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension NuGet, as we can see in the Image 5:

Image 5 Updating Nuget

And then, click "I Accept"

Image 6 License

We get

Image 7 NuGet packages updated

With this another question can be raised, "Did we update all NuGet packages we can?" and this question can be found by uninstalling the Microsoft Azure Mobile Services .NET Backend Entity Framework Extension NuGet, as in the Image 8

Image 8 Uninstall Nuget

Uninstall this NuGet will request a confirmation to uninstall all dependencies, as in the Image 9, where we will click in "Yes".

Image 9 Nuget packages to remove

The result will be

Image 10 The service running in localhost

And the package file updated to:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="3.5.2" targetFramework="net45" />
  <package id="AutoMapper" version="3.2.1" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.0.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.2" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.ActiveDirectory" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Jwt" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="RazorEngine" version="3.4.1" targetFramework="net45" />
  <package id="System.IdentityModel.Tokens.Jwt" version="3.0.2" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.2" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend" version="1.0.447" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Entity" version="1.0.447" targetFramework="net45" />
  <package id="WindowsAzure.MobileServices.Backend.Tables" version="1.0.447" targetFramework="net45" />
  <package id="WindowsAzure.ServiceBus" version="2.3.4.0" targetFramework="net45" />
</packages>

Returning back to the "Updates", we will see the NuGet packages, in the Image 11 that we can update, but for the reasons we saw, it is not possible to update all.

Image 11 Manage NuGet Packages

Conclusion

In conclusion, each developer should be aware of the dependencies between NuGet packages and more than one package can depend from the same NuGet package but for different versions, this means is required to keep the versions used by each one.