EF Code First - Timeout expired. The timeout period elapsed prior to completion

后端 未结 6 1176
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 23:34

Apology for this strangely worded question. I don\'t know what the actual problem is but hopefully someone can give me some insights.

I am getting the following error wh

6条回答
  •  借酒劲吻你
    2021-02-07 00:07

    I ran into this in my production environment because it was producing queries like the ones here: Why does Entity Framework 6 generate complex SQL queries for simple lookups?

    This is actually related to a bug in this version of EF: https://entityframework.codeplex.com/workitem/2083

    They changed the default null semantics from 5 to 6 so I'm guessing you had the same problem I did after upgrading. My machine had a fraction of the data as my remote installation and until I got to production I didn't know I had a performance issue. The queries will often produce a table scan which will time out for larger tables.

    To change it back so that it works like EF5 you have to set:

    DbContextConfiguration.UseDatabaseNullSemantics = true

    See here: http://msdn.microsoft.com/en-us/library/system.data.entity.infrastructure.dbcontextconfiguration.usedatabasenullsemantics(v=vs.113).aspx

    The bug was fixed in EF 6.1 but you still have to set the option above to get simple where conditions.

提交回复
热议问题