I created a Web API project under VS 2010. After I switched to VS 2012, I always get a warning:
The Web project 'xxx' requires SQL Server Express, whcih is not installed on this computer. [...]
I do not want to install this SQL Server Express. I use IIS for debugging. How can I disable this dependency?
I noticed also this in my web.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|[...].mdf;Initial Catalog=[...];Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>
Who created this? Can I delete this?
The next step is to create the ASP.NET membership and School databases. From the View menu select Server Explorer (Database Explorer in Visual Web Developer), and then right-click Data Connections and select Create New SQL Server Database. In the Create New SQL Server Database dialog box, enter ".
Although ASP.NET Web API is packaged with ASP.NET MVC, it is easy to add Web API to a traditional ASP.NET Web Forms application. To use Web API in a Web Forms application, there are two main steps: Add a Web API controller that derives from the ApiController class. Add a route table to the Application_Start method.
An API is supposed to provide services without being coupled with its consumer application. There is a common misconception that for developing Web APIs, we have to go by ASP.NET MVC application. In this article, we will develop an independent API which is not coupled with a ASP.NET MVC application type.
Change this part of the connection string "Data Source=.\SQLEXPRESS" to
"Data Source=localhost\SQLEXPRESS"
It was created by Visual Studio to you. The reason is Web API projects are a sub class of MVC projects. And actually, Web API project can contain both: a web application and Web API itself.
As far as this project is a sub class of an MVC project you get all this extra features.
You can delete all that extra stuff as far as you don't need it. The things you can delete also:
In WebConfig:
You probably would also want to delete
NuGet packages:
Everything except razor, MVC, Web Api packages like:
In Solution Explorer:
But be cautious, because after that deletion you won't be able to add Web API Help page for example (which describes your API).
you can also change the connection string to the new SQL 2014+ syntax "Data Source=(LocalDb)\MSSQLLocalDB;..." if you have a later version of SQL Express local db installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With