简体   繁体   English

体系结构ASP.NET MVC 5

[英]architecture ASP.NET MVC 5

I am working on project using ASP.NET MV5 along with Entity Framework. 我正在使用ASP.NET MV5和Entity Framework进行项目。 I got few question related to architecture application in best possible way. 我很少遇到与架构应用有关的最佳问题。 I Got existing database so i will use code first existing database approach (code or design?) possibly i will use the store procedure as well 我有现有数据库,所以我会先使用代码,然后再使用现有数据库方法(代码还是设计?),可能也会使用存储过程

now if i use code first existing database design approach, should i have separate models for each business concern or one design (ADO.NET Entity Model). 现在,如果我先使用代码,则应该使用现有的数据库设计方法,是否应该针对每个业务问题或一个设计使用单独的模型(ADO.NET实体模型)。 I have just realize some of my model will share among different business functions for example ASP.NET Identity table "Role" is using my dashboard controller where it see, who can use what functions! 我刚刚意识到我的某些模型将在不同的业务功能之间共享,例如ASP.NET身份表“角色”正在使用我的仪表板控制器,谁可以使用哪些功能!

can i mix code first existing database--> design & code approach together? 我可以将代码优先存在的数据库->设计和代码方法混合在一起吗?

if i use code first existing database design approach, can i go and modify model? 如果我先使用代码,就可以使用现有的数据库设计方法来修改模型?

should i have one DbContext for reading database or separate? 我应该有一个用于读取数据库的DbContext还是单独的? reason why i am asking if code running under one DbContext brings all data! 我问为什么在一个DbContext下运行的代码会带来所有数据的原因! do i really need that? 我真的需要吗? does it effect performance? 它会影响性能吗? security otherwise have multiple DbContext for each business concerns? 安全性,否则每个业务都有多个DbContext?

I know it is very open questions. 我知道这是非常开放的问题。 i more interesting to see other expert approach in architecture complex application in best possible way using ASP.NET technologies. 我更感兴趣的是使用ASP.NET技术以最佳方式查看体系结构复杂应用程序中的其他专家方法。

Many Thanks 非常感谢

For small projects, it's probably ok to just use your entity objects directly. 对于小型项目,直接使用实体对象可能是可以的。 However, if you want to perform complex validation and apply business rules, you're much better off creating separate business objects. 但是,如果要执行复杂的验证并应用业务规则,则最好创建单独的业务对象。 Entity objects are, by nature, data objects only. 本质上,实体对象仅是数据对象。

You can use utilities like AutoMapper to make translating between entity and business objects much easier and eliminate errors and inconsistencies while maintaining clear separate between your business objects and your entity objects. 您可以使用诸如AutoMapper之类的实用程序来简化实体和业务对象之间的转换,并消除错误和不一致之处,同时保持业务对象和实体对象之间的清晰区分。

In the long run, this is a more sustainable architecture. 从长远来看,这是一个更具可持续性的体系结构。

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

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