架构决策:ASP.NET MVC &实体框架 [英] Architectural decisions: ASP.NET MVC & Entity Framework

查看:26
本文介绍了架构决策:ASP.NET MVC &实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了架构决策问题:我们即将构建一个新的应用程序,我们决定使用 ASP.NET MVC实体框架(可能首先是数据库).最初,我们只会为常规浏览器构建 Web 应用程序,但将来我们可能会添加移动应用程序.(SOA?)

I'm having an architectural decision-problem: We're about to build a new application and we've decided we'll be using ASP.NET MVC and Entity Framework (database first probably). In the first fases we'll only be building a web application for regular browsers, but in the future we might add mobile applications. (SOA?)

我现在的问题是构建应用程序架构的最佳方式是什么?

My question is now what would be the best way to build up the application architecture?

这是正确的吗?

  1. MVC 项目
    • 模型
    • 查看
    • 控制器
  • 保存 edmx 和 T4 模板

我一直在寻找示例、模式和最佳实践,但似乎找不到合适的内容.

I've been searching for examples, patterns and best practices but I can't seem to find something that fits just right.

谢谢!

推荐答案

我通常构建解决方案的方式(编辑适用于 NuGet)

The way I normally structure my solutions (edit adapted for NuGet)

  1. 网站 (MVC)
    • 控制器
    • 观看次数
    • 内容(脚本、CSS、图像等)
  • 查看模型
  • 模型映射器
  • 规则
  • 本地扩展(Web 和常规)
  • 存储库
  • 实体模型
  • 数据上下文和配置
  • 扩展(到 MVC/Web 类)
  • 助手类= 属性
  • 扩展
  • 助手类

依赖关系沿着这个结构向上流动,即上面的东西可能会引用下面的东西,但反之则不然.每个项目我也会有一个单独的测试项目.在某些情况下,我将外部共享库用于与 NuGet 打包并托管在本地存储库上的 Web/通用类.

Dependencies flow up this structure, i.e., the things above might reference the things below, but not vice versa. I would also have a separate test project per project. In some cases, I use external, shared libraries for web/general classes packaged with NuGet and hosted on a local repository.

对于移动设备,如果您通过网络访问,我会使用 jQuery Mobile 和移动感知视图引擎将其直接构建到网站中.如果您考虑本机,那么我会添加一个 WebAPI 层,该层可能会或可能不会与用于 API 交付的网站共享相同的视图模型,并针对 API 在此结构之外开发移动应用程序.API 很可能有自己的模型,并位于业务层之上的一个单独的堆栈中.在我当前的项目中,我们将数据放在单独的解决方案中,并在单独的解决方案中开发 API 和网站,通过 NuGet 包共享模型.

For mobile, if you're going via the web, I would build that directly into the WebSite using jQuery Mobile and mobile-aware view engines. If you're thinking native, then I'd add a WebAPI layer that may or may not share the same view models as the web site for API delivery and develop the mobile app outside this structure against the API. Most likely the API has it's own models and sits above the business layer in a separate stack. In my current project, we have the data in a separate solution and are developing the API and web site in separate solutions, sharing models via NuGet packages.

这篇关于架构决策:ASP.NET MVC &实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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