简体   繁体   English

对另一个项目 ASP.NET MVC 的模型引用

[英]Model Reference to another project ASP.NET MVC

There is a completed ASP.NET MVC project.有一个完整的 ASP.NET MVC 项目。

In that project, it already has the company employee main data.在那个项目中,它已经有了公司员工的主要数据。

So I want to create another project but, I don't think that creating another table in this new project for the employees and again saving the same details is an unnecessary thing.所以我想创建另一个项目,但是我不认为在这个新项目中为员工创建另一个表并再次保存相同的细节是不必要的。

So is there any way of accessing those data from another project?那么有没有办法从另一个项目中访问这些数据呢?

As Example,例如,

Project 1 has a model called EmployeeMain and this project has CRM_UAT Database. Project 1有一个名为EmployeeMain的模型,这个项目有 CRM_UAT 数据库。

Project 2 need to access the model called EmployeeMain from project 1 to create user accounts and save them in the DCS_UAT database. Project 2需要访问项目 1 中名为EmployeeMain的模型,以创建用户帐户并将其保存在DCS_UAT数据库中。

So how can I handle this kind of things?那么我该如何处理这种事情呢?

Create a separate project to handle the data access.创建一个单独的项目来处理数据访问。 and referencing that project with your project 1 and project 2 would be a good practice.并使用您的项目 1 和项目 2 引用该项目将是一个很好的做法。

You may also look into clean architecture and repository pattern will give you a good idea.您还可以研究干净的架构和存储库模式会给您一个好主意。

https://codewithmukesh.com/blog/onion-architecture-in-aspnet-core/ https://codewithmukesh.com/blog/onion-architecture-in-aspnet-core/

https://www.c-sharpcorner.com/article/onion-architecture-in-asp-net-core-mvc/ https://www.c-sharpcorner.com/article/onion-architecture-in-asp-net-core-mvc/

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM