简体   繁体   English

带有RIA服务的实体框架,Silverlight - 脱钩与快速开发的权衡

[英]Entity Framework with RIA services, Silverlight - tradeoff of decoupling versus rapid development

I've been playing around lately with Entity Framework, WCF RIA Services, and Silverlight 4. I'm impressed by how rapidly you can develop an application with these tools, and you get a lot "for free", such as the Silverlight UI automatically knowing about certain validations that are included as DataAnnotations on the EF model. 我最近一直在玩Entity Framework,WCF RIA Services和Silverlight 4.我对使用这些工具开发应用程序的速度感到印象深刻,并且你获得了很多“免费”,例如Silverlight UI自动了解EF模型中作为DataAnnotations包含的某些验证。 However, it seems like in a large application it would be undesirable to have a dependency on EF pushed all the way through the entire application including the business logic and UI. 但是,在大型应用程序中,似乎不希望在整个应用程序(包括业务逻辑和UI)中一直推动EF的依赖。

I know that you can use POCO / IPOCO with Entity Framework, and that is certainly an option for me. 我知道您可以将POCO / IPOCO与实体框架一起使用,这对我来说无疑是一个选择。 However, if you go that route, you lose some of the "automagic" stuff such as Silverlight being able to show model validations without any extra work. 但是,如果你走这条路,就会失去一些“自动化”的东西,比如Silverlight能够在没有任何额外工作的情况下显示模型验证。

How are people dealing with this? 人们如何处理这个问题? Do you give up some of the power and put interfaces in between the different layers in order to decouple the other layers from EF? 你是否放弃了一些功能并将接口放在不同的层之间,以便将其他层与EF分离? Or do you give up on decoupling in order to allow for more rapid development? 或者你是否放弃了解耦以便更快地发展? Is there some way to have my cake and eat it too that I'm not seeing? 有没有办法让我的蛋糕吃掉,我没有看到?

My group is currently dealing with this exact issue. 我的小组目前正处理这个问题。 We came up with a decent compromise that everyone was happy with. 我们想出了一个让每个人都满意的妥协方案。 Keep in mind that before it is all over with, projects become more complicated over time and maintainability is key. 请记住,在它结束之前,项目会随着时间的推移变得更加复杂,可维护性是关键。 You also want to increase code reuse as much as possible so replacing your UI (or unit testing) is a minimized effort. 您还希望尽可能地增加代码重用,因此更换UI(或单元测试)的工作量最小化。

Given all this, we favored a well defined domain layer instead of pushing EF all the way through to the UI. 鉴于这一切,我们倾向于定义良好的域层,而不是将EF一直推送到UI。 This makes the model the heart of the application and doesn't force us to conform to the schema of our database. 这使得模型成为应用程序的核心,并不会强迫我们遵循数据库的模式。 I know EF tries to abstract that away with its conceptual model, but we kept running into little gotchas that made it more and more difficult to rely on EF for the full stack. 我知道EF试图通过它的概念模型来抽象它,但是我们一直在遇到一些小问题,这使得依赖EF完全堆栈变得越来越困难。 For instance, there really isn't a great place to put business logic with EF. 例如,确实没有一个将业务逻辑与EF放在一起的好地方。 We didn't want to put that stuff into Interceptors and we didn't want to put it in the UI. 我们不想把这些东西放到拦截器中,我们不想把它放在UI中。 Sure, there might be a clever workaround for this, but we weren't liking the direction we were being pushed. 当然,可能有一个聪明的解决方法,但我们不喜欢我们被推动的方向。

The compromise was to use EF but to keep it between the data store and the domain model. 折衷方案是使用EF,但要将其保留在数据存储和域模型之间。 This way we still don't have to program against DataReaders, and we can leverage the benefits of self-tracking entities in the domain. 这样我们仍然无需针对DataReader进行编程,我们可以利用域中自跟踪实体的优势。 We then expose basic WCF services (not RESTful) from our domain to our UIs. 然后,我们将基本的WCF服务(不是RESTful)从我们的域暴露给我们的UI。

To us, the extra validation work wasn't really THAT big a deal. 对我们来说,额外的验证工作并不是真的很重要。 Sure, our initial release takes a little more time, but the overall maintenance cycle doesn't take as long because we aren't finagling with the complexities of the framework. 当然,我们的初始版本需要花费更多的时间,但整个维护周期并不需要很长时间,因为我们没有完成框架的复杂性。

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

相关问题 具有实体和RIA Services / Silverlight的自定义类 - Custom class with an entity and RIA Services/Silverlight 如何编辑绑定到ria服务然后绑定到Entity Framework和SQL递归表的Silverlight树视图数据 - How to Edit a Silverlight treeview data bound to ria services then to Entity Framework and SQL recursive table 需要帮助调试:无法通过RIA服务,实体框架,MySQL将数据获取到Silverlight应用程序 - Need help debugging: Having trouble getting data to Silverlight App through RIA Services, Entity Framework, MySQL 使用Entity-Framework和Silverlight WCF RIA-Services开发自定义授权服务? - Developing custom authorization service with Entity-Framework and Silverlight WCF RIA-Services? 实体框架/ RIA服务包括不工作 - Entity Framework / RIA Services Include not working 具有继承和RIA服务的实体框架模型 - Entity Framework Model with inheritance and RIA Services Visual Studio Express 2013和Silverlight RIA Services开发 - Visual Studio Express 2013 and Silverlight RIA Services development RIA服务与WCF服务 - RIA Services versus WCF Services Silverlight 4,Ria服务,HttpRequestTimedOutWithoutDetail - Silverlight 4, Ria Services, HttpRequestTimedOutWithoutDetail 使用RIA服务在Silverlight中进行过滤 - Filtering in Silverlight with RIA Services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM