config.MapODataServiceRoute错误 [英] config.MapODataServiceRoute error

查看:715
本文介绍了config.MapODataServiceRoute错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前按照本指南 - > <一个href=\"http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint\">Link到asp.net网站

I am currently following this guide -> Link to asp.net website

由于导说,我通过的NuGet控制台添加所有必需的包,并添加了必要的usings到WebApIConfig文件。 。但是,当我加入了端点注册方法VS给了我一个错误。

As the guide says I added all the necessary packages via the nuget console and added the necessary usings to the WebApIConfig file. . But when I added the endpoint register method VS gave me an error.

我添加的方法:

public static void Register(HttpConfiguration config)
    {
        // New code:
        ODataModelBuilder builder = new ODataConventionModelBuilder();
        builder.EntitySet<Product>("Products");
        config.MapODataServiceRoute(
            routeName: "ODataRoute",
            routePrefix: null,
            model: builder.GetEdmModel());
    }

该错误VS递给我:

The Error VS gave me:

Error   1   'System.Web.Http.HttpConfiguration' does not contain a definition for 'MapODataServiceRoute' and no extension method 'MapODataServiceRoute' accepting a first argument of type 'System.Web.Http.HttpConfiguration' could be found (are you missing a using directive or an assembly reference?) C:\Users\rvcamp\Desktop\odataTest\odataTest\App_Start\WebApiConfig.cs   29  20  odataTest

我检查指导的意见,但没有提到这个错误,也是我也不能纠正错误。我究竟做错了什么?

I checked the comments of the guide but this error is not mentioned, also I can not resolve the error either. What am I doing wrong?

推荐答案

我只是有这个问题。非常令人沮丧的。

I just had this problem. Very frustrating.

我通过在code页

using System.Web.OData.Extensions;

右键单击该方法并没有弹出决心菜单项任。

Right clicking the method did not bring up the resolve menu item either.

重新安装一切为我做的没有解决任何问题。

Reinstalling everything did no resolve anything for me.

这篇关于config.MapODataServiceRoute错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆