将MVC EF转换为三层架构模型 [英] converting MVC EF to 3-Tiers Architecture model

查看:144
本文介绍了将MVC EF转换为三层架构模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在使用MVC3&实体框架和项目模型仅与我的entity.emdx有关. 现在,我想将此项目转换为三层体系结构,该体系结构将涉及: (表示层:我的旧MVC项目的视图和控制器), (业务层:与数据库有关的所有操作), (数据访问层:我的实体框架(.emdx)), 这就是我的结论, 如果我是正确的,那么MVC项目(表示层)中的模型将为空,是否可以在不包含模型的MVC中使用? 如果我的想法是错误的,那么正确的做法是什么?

I was working on my project using MVC3 & Entity framework and the model of my project was about my entity.emdx only. now i want to convert this project to 3-tiers architecture that will be about: (presentation layer :my old MVC project's views and controllers), (business layer:all operations related to data base), (data access layer: my entity framework(.emdx)), This is what i concluded,, and if i am correct then the model in the MVC project (presentation layer) will be empty ,,,is it possible in MVC that doesn't contain Models?, if my thinking is wrong so, what is the correct thing to do?

推荐答案

是的,可能没有模型,您创建的数据访问层现在充当表示层中的模型(当它是1层时) ..

Yeah its possible to don't have model, the data access layer you created is now act as the Model found in presentation layer(when it was 1 tier)..

模型现在是数据访问中的实体,但是由于某种原因,例如,如果要创建ViewModel,您可以在3层应用程序中使您的模型成为可能,有关此示例,请参见以下示例:

The Models now are the entities in the data access, but you Make can your Model even in 3 tier application for some reason like if you want to create ViewModel, see this example about it:

http://www.edandersen.com/2013/05/30/asp-net-mvc-basics-part-2-viewmodel-to-model-mapping-and-editing/

这篇关于将MVC EF转换为三层架构模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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