0

I'm following this video on creating service stack for Entity Framework and the video uses

config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel());

in their WebApiConfig file. I am using the same piece of code in my project and I'm getting this error:

System.InvalidOperationException: 'The complex type 'ClassLibrary1.Session' refers to the entity type 'ClassLibrary1.Customer' through the property 'Customer'.'

for this piece of code:

var builder = new ODataConventionModelBuilder();
builder.EntitySet<Customer>("Customers");
config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel());

And when I hover over the method it says deprecated:

enter image description here

So what do I use here to get the same output of the video.

Jay Modi
  • 569
  • 7
  • 24
  • 1
    I've removed the `[servicestack]` tag as this video uses OData with EF & MVC and not [ServiceStack](https://servicestack.net). – mythz Jul 11 '21 at 12:48
  • Looking at the error, the namespace from which you're getting your MapODataRoute is deprecated. Use it via provided namespace and check if any other package is needed instead. Package name should be similar to namespace provided in the error. – touchofevil Jul 11 '21 at 13:05
  • @touchofevil I did try it following this https://stackoverflow.com/questions/27224702/config-mapodataserviceroute-error where I changed MapODataRoute to MapODataServiceRoute but I'm still getting the same error saying the complex type refers to the entity type. – Jay Modi Jul 11 '21 at 13:23

0 Answers0