情况:我有两个应用程序.一个是API,另一个是我的Web应用程序.
Situation: I have two Applications. One is an API and the other is my Web Application.
编辑:只有API有权访问数据库
edit: only the API has Access to the Database
想法:是否可以在我的Web应用程序中将Entity Framework和API用作数据源,而不是实际的数据库?
Idea: Is it possible to also use Entity Framework in my Web Application with the API as Datasource instead of an actual Database?
推荐答案如果我很了解您的情况,那么您有两个连接到同一数据库的应用程序?我认为您有两种选择:
If I good understand your case, you have two applications which are connected to the same database? I think you have two options:
首先是使用数据库访问逻辑创建第三个项目存储库",并在两个应用程序中都使用它.
First is create third project "Repository" with database access logic and use it in both applications.
将您的API用作WebApplication数据的来源-仅来自WebApp控制器中的操作即可对您的api进行HTTP调用(例如 localhost/api/path ).
Use your API as source for WebApplication Data - just from actions in WebApp controllers make HTTP calls to your api (eg. localhost/api/path).
更多推荐
带有REST API作为数据源的.NET Core实体框架?
发布评论