【问题标题】:We are using EntityFrame work in a singleton class ? - Not reflecting the DataBase changes in the front End我们在单例类中使用 EntityFrame 工作? - 不反映前端的数据库变化
【发布时间】:2010-03-23 14:18:54
【问题描述】:

我们的应用程序使用 Entity Framework(.net 3.5) 和 singleton 。当我通过程序在后端更新时。它没有反映在实体上下文中。

我尝试刷新 - 但它没有刷新外键。

如何在 Entity Framework 中刷新整个上下文?

【问题讨论】:

    标签: c# entity-framework .net-3.5


    【解决方案1】:

    您是否尝试单例化 objectcontext 对象?我不建议这样做。最好为每个“工作单元”实例化一个新的对象上下文。如果您这样做,您的“实体上下文”将始终是最新的。

    http://blogs.msdn.com/alexj/archive/2009/05/07/tip-18-how-to-decide-on-a-lifetime-for-your-objectcontext.aspx

    Instantiating a context in LINQ to Entities

    【讨论】:

    • 我们尝试在我们的存储库类中使用 (MyContext ctx = new MyContext()) { ... }。但这会为 foreginkey 抛出一些其他错误。如何克服?
    • 听起来您的数据库表可能有问题。另见stackoverflow.com/questions/520065/…
    猜你喜欢
    • 1970-01-01
    • 2021-09-25
    • 1970-01-01
    • 2014-10-07
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    相关资源
    最近更新 更多