Check your ODataController name, it needs to be aligned with EntitySet name in your edmx.
If the set name is CustomerSet, controller needs to be CustomerSetController with a public GetCustomerSet method.
For instance this works;
TestDbContext.cs
public partial class TestDbContext : DbContext
{
public TestDbContext()
: base("name=TestDbContext")
{}
public virtual DbSet<A1> A1Set { get; set; }
}
A1SetController.cs
public class A1SetController : ODataController
{
private TestDbContext db = new TestDbContext();
// GET odata/A1Set
[Queryable]
public IQueryable<A1> GetA1Set()
{
return db.A1Set;
}
}
And routing setup in WebApiConfig.cs
// OData routes
config.Routes.MapODataRoute(
routeName: "odata",
routePrefix: "odata",
model: EdmBuilder.GetEdm<TestDbContext>(),
batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
And last, edmx and actual model (class) namespaces need to be aligned. When you make a request to $metadata, you see the defined namespace for your model. You can change it in your Model Designer, right click to an empty area, click to Properties. In Properties window, you can see Namespace attribute. In my case;
<Schema Namespace="Web">
<EntityType Name="Customer">
And Customer.cs
namespace Web
{
using System;
using System.Collections.Generic;
public partial class Customer
{
public int Id { get; set; }
public string Name { get; set; }
}
}