带有REST API作为数据源的.NET Core实体框架? [英] .NET Core Entity Framework with a REST API as Datasource?

查看:37
本文介绍了带有REST API作为数据源的.NET Core实体框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:我有两个应用程序.一个是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:

  1. 首先是使用数据库访问逻辑创建第三个项目存储库",并在两个应用程序中都使用它.

  1. First is create third project "Repository" with database access logic and use it in both applications.

将您的API用作WebApplication数据的来源-仅来自WebApp控制器中的操作即可对您的api进行HTTP调用(例如

Use your API as source for WebApplication Data - just from actions in WebApp controllers make HTTP calls to your api (eg. http://localhost/api/path).

这篇关于带有REST API作为数据源的.NET Core实体框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆