自我跟踪实体不再推荐。什么是? [英] Self-tracking entities not recommended anymore. What is?

查看:116
本文介绍了自我跟踪实体不再推荐。什么是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读有关EF 5.0和n层解决方案的msdn信息查看链接,似乎MS不推荐STE,POCO / DTO方式也不推荐说是很难的。



不是全部(也许不是很多?)应用程序适合使用WCF数据服务。那么有什么办法呢?我的场景是一个目前的大型服务器(WebServices)应用程序,其中包含许多客户端(仅我们自己的),大多是WinForms。今天DataSets用于发送数据并跟踪更改到SQL Server数据库。



我们现在开始用WCF替换WebServices,并且还在研究使用Entity Framework 。我们不需要首先进行代码或迁移,因为我们已经有数据库到位,还有很多可以被重用的存储过程。
由于我们没有任何客户不是我们自己的问题,STE似乎是一个不错的选择,但我们不想开始使用EF团队显然不推荐的东西。 POCO / DTO也是一种替代方案,尤其是与客户明确分离。我知道有更多的工作要做,然后与CUD,但是这是非常困难的建议是要远离,那么我不知道我们是否想走下去。



然后,根据推荐,我们应该使用WCF数据服务或Web API,但是这对于基于操作的服务来说真的不是一种替代方案,需要对协议/格式等有灵活性。 >

所以我的问题是,今天最好的做法是什么?

解决方案

认为这个想法是更普遍地移动到更轻的重量pocos / dtos,并在您的DAL中保持任何所有持久性逻辑或实现。自我跟踪实体排除了一些实现,并使您的实体肥胖。你会获得方便,但松散的灵活性,因为愚蠢的dto可以很容易地传递,几乎没有惊喜。



当然,另一方面,你需要做更多的工作在你的dal跟踪上下文,您需要在BLL和UI中进行更多的工作来处理填充/映射dto。



我个人更喜欢灵活性方便,似乎是一般情况如何。


Reading the msdn information on EF 5.0 and n-tier solutions see link , it seems that MS is not recommending STE's and the POCO/DTO way is also not recommended by stating that it is difficult.

Not all (perhaps not many?) applications are suited for using WCF Data Services. So what is the way to go? My scenario is a current, large server (WebServices) application with many clients (only our own), mostly WinForms. Today DataSets are used to ship the data and track changes into the SQL Server database.

We are now starting to replace WebServices with WCF and are also looking into using the Entity Framework. We don't need code first or migrations since we already have the database in place and a lot of stored procedures that will be reused. Since we don't have any issues with clients being other than our own, STE's seemed like a good choice, but we don't want to start using something that the EF team is clearly not recommending anymore. POCO/DTO has also been an alternative, not least for the clear separation against the clients. I know there is more work to be done then with the CUD, but is it so difficult that the recommendation is to stay away, then I don't know if we want to go down that road.

Then, according to the recommendation we should use WCF data services or Web API, but that is really not an alternative for a operation-based service that needs to be flexible about protocol/format etc.

So my question is, what is best-practice today?

解决方案

I think the idea is to move more generally to lighter weight pocos/dtos and keeping any an all persistence logic or implementation in your DAL. Self tracking entities sort of bleed some of that implementation out and fatten up your entities. You gain convenience, but loose flexibility as dumb dto's can be passed around easily with few suprises.

Of course the flip side to that is you need to do more work in your dal to track context and you need to do more work in your BLL and UI to deal with populating/mapping dto's.

I personally prefer flexibility over convenience and that seems to be the way things are going in general.

这篇关于自我跟踪实体不再推荐。什么是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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