如何在ASP.NET WebAPI解决方案中将引用从WebAPI添加到DataModel

时间:2018-10-25 04:07:09

标签: asp.net asp.net-web-api

我创建了一个解决方案,在其中创建了2个项目,一个用于Web api,另一个用于数据模型。如何在Web API项目中使用数据模型?

2 个答案:

答案 0 :(得分:1)

为什么有2个解决方案。实际上,您可以有一个包含2个项目的解决方案文件。 构建解决方案后,您可以在数据模型项目中看到一个dll。您必须通过右键单击引用在项目Web API中添加该dll的引用,并在数据模型项目所在的位置添加引用。单击并添加。大功告成通过使用正确的名称空间访问webapi中的数据模型。

答案 1 :(得分:1)

1. Right click the project you want to use the data type in

2. Tick all the projects you want the selected project to have access too

3. Add a using statement at the top of every class file that you want to use the data model in

  1. 右键单击要在其中使用数据类型的项目
  2. 勾选所有您希望所选项目也具有访问权限的项目
  3. 在要在其中使用数据模型的每个类文件的顶部添加using语句