modelBuilder.CacheForContextType在CTP5中不可用 [英] modelBuilder.CacheForContextType not available in CTP5

查看:58
本文介绍了modelBuilder.CacheForContextType在CTP5中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CTP5中用modelBuilder.CacheForContextType属性替换了什么?

What has the modelBuilder.CacheForContextType property been replaced with in CTP5?

 

谢谢,

Fred

Thanks,
Fred

推荐答案

我们删除了CTP5中的CacheForContextType,我们原本打算当人们希望在具有不同模型的同一AppDomain中使用相同的上下文时,可以使用它。问题是它会在每次初始化时创建模型,并且不允许任何方式
缓存一系列模型并选择在每次初始化期间使用哪一个模型。模型创建很昂贵,因此我们希望推广更好的模式。

We removed CacheForContextType in CTP5, we originally intended it to be used when folks wanted to use the same context in the same AppDomain with different models. The issue is that it would create the model on every initialization and didn't allow any way to cache a series of models and choose which one to use during each initialization. Model creation is expensive so we wanted to promote a better pattern.

我们推荐的模式是从外部创建模型构建器 - > DbDatabaseMapping - >要使用的每个模型的DbModel。应该缓存DbModel并将其用于创建上下文实例。 ModelBuilder - > DbModel工作流程是
a有点乱,类名不是很好,它们将被整理为RTM。

The pattern we recommend is to externally create a ModelBuilder -> DbDatabaseMapping -> DbModel for each model you want to use. The DbModel should be cached and used to create context instances. The ModelBuilder -> DbModel workflow is a little messy and the class names aren't great, they will be tidied up for RTM.

~Rowan

这篇关于modelBuilder.CacheForContextType在CTP5中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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