ASP.NET Web Api: Project requires SQL Server Express

前端 未结 3 2047
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 00:12

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

3条回答
  •  佛祖请我去吃肉
    2021-02-05 01:06

    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:

    • /configSections/section name="entityFramework"...
    • /connectionStrings
    • /system.web/pages
    • /system.web/profile
    • /system.web/membership
    • /system.web/roleManager
    • /entityFramework

    You probably would also want to delete

    NuGet packages:

    Everything except razor, MVC, Web Api packages like:

    • jQuery
    • EntityFramework
    • jQuery Validation
    • jQuery UI
    • Modernizr
    • knockoutjs
    • MS Unobtrusive AJAX
    • MS Unobtrusive Validation

    In Solution Explorer:

    • /App_Data
    • /Content
    • /Images
    • /Scripts
    • /Views

    But be cautious, because after that deletion you won't be able to add Web API Help page for example (which describes your API).

提交回复
热议问题