Route not working for Web Api Odata

Topics: ASP.NET Web API
Jan 31, 2013 at 4:06 PM
I am having serious difficulty getting the oData support to work with the Web Api.

Followed this link for creating a simple odata controller.

I have used Nuget to get the latest nightly builds of the OData dependencies.

Added this to the bottom of Application_Start in Global.asax.cs
            ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder();
            modelBuilder.EntitySet<Movie>("Movies");
            IEdmModel model = modelBuilder.GetEdmModel();

            GlobalConfiguration.Configuration.Routes.MapODataRoute(routeName: "OData", routePrefix: "odata", model: model);
Here is my controller.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.OData;

namespace MvcApplication2.Controllers
{
    public class MoviesController : EntitySetController<Movie, int>
    {
        List<Movie> _movies = new List<Movie> { 
            new Movie{id = 1, name = "movie 1"},
            new Movie{id = 2, name = "movie 2"},
            new Movie{id = 3, name = "movie 3"},
            new Movie{id = 4, name = "movie 4"},
        };

        [Queryable]
        public override IQueryable<Movie> Get()
        {
            return _movies.AsQueryable();
        }

        protected override Movie GetEntityByKey(int key)
        {
            return _movies[key];
        }

        protected override Movie PatchEntity(int key, Delta<Movie> patch)
        {
            Movie movieToPatch = _movies[key];
            patch.Patch(movieToPatch);
            return movieToPatch;
        }
    }
}
Movie is a very basic class
namespace MvcApplication2
{
    public class Movie
    {
        public int id { get; set; }
        public string name { get; set; }
    }
}
BUT, when I try to access the list I get a 404.
 The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /odata/Movies
I have made no further changes to the default MVC 4 Web API Application template in Visual Studio 2012.

Am I missing a setting to get this working?

Thanks to anyone who can offer advice.
Jan 31, 2013 at 4:16 PM
Don't I feel a bit silly. Oops!

Define the odata route BEFORE the default route defined in RouteConfig.RegisterRoutes.

Problem Solved.

Cheers