带有REST API作为数据源的.NET Core实体框架?

编程入门 行业动态 更新时间:2024-10-26 18:25:01
本文介绍了带有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:

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

  • 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实体框架?

    本文发布于:2023-11-04 17:33:10,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1558571.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:数据源   实体   框架   REST   API

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!