I am working with a straightforward entityframework poco object
public partial class Location: Entity
{
[Key]
public int Id { get; set; }
public string Description { get; set; }
}
The baseClass Entity is structured as below
public abstract class Entity : IObjectState
{
[NotMapped]
public ObjectState ObjectState { get; set; }
}
I have exposed this object through an Odata service using the ODataConventionModelBuilder
var server = GlobalConfiguration.DefaultServer;
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.Namespace = "MyNameSpace.Models";
builder.EntitySet<Location>(typeof(Location).Name);
var model = builder.GetEdmModel();
config.Routes.MapODataServiceRoute("odata", "odata", model, new DefaultODataBatchHandler(server));
config.AddODataQueryFilter();
However, when attempting to consume this service with Breeze js and creating an entity with manager.CreateEntity(), an error is encountered.
Cannot attach an object to an EntityManager without first setting its key or setting its entityType 'AutoGeneratedKeyType' property to something other than 'None'
Interestingly, editing and saving an entity after querying works fine.
The client side technology being used includes angular with breeze, while on the server side Asp.net webapi 2 is combined with an odatacontroller and EntityFramework 6 as ORM.
If anyone can identify what might be going wrong here, please let me know!