How to: Install Web API NuGet Package on .NET Framework 4.0
This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.
With the introduction of ASP.NET Web API 2, Microsoft has made the latest versions of the respective NuGet package to require .NET 4.5. This means that versions later than 4.0.30506 of the ASP.NET Web API NuGet package can be installed only in projects targeting .NET 4.5. If you try to manually install the latest version of the NuGet package in a project targeting version 4.0 of the .NET framework, you will receive the following error:
Could not install package 'Microsoft.AspNet.WebApi.Client 5.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework.
Generally when creating a Web API Service, Telerik Data Access will always try to install the latest version of the Web API NuGet package. However, if the host project for the service targets .NET 4.0, Telerik Data Access will not install the NuGet automatically. Therefore, when building the project you would get the following errors:
The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
The type or namespace name 'HttpResponseMessage' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
In order to avoid this, we recommend you use a .NET 4.5 project for the service host.
In case this is not possible, you can manually download and install, in the project that hosts the service code base, version 4.0.30506 of the ASP.NET Web API NuGet package by executing the following command in the Package Manager Console:
Get-Project <service_code_base_project_name> | Install-Package Microsoft.AspNet.WebApi -Version 4.0.30506
Note that installing an old version of the ASP.NET Web API NuGet package may cause security issues in your application and you will not be able to take advantage of bug fixes and new features that may be offered in later versions.