Is it good to use a static EF object context in an MVC application for better perf?

后端 未结 3 1077
刺人心
刺人心 2021-01-22 10:48

Let\'s start with this basic scenario:

I have a bunch of Tables that are essentially rarely changed Enums (e.g. GeoLocations, Category, etc.) I want to load these into

3条回答
  •  情书的邮戳
    2021-01-22 10:54

    I've implemented something similar using Linq2SQL by retrieving these 'lookup tables' as lists on app startup and storing them in ASP's caching mechanism. By using the ASP cache, I don't have to worry about threading/locking etc. Not sure why you'd need to attach them to a context, something like that could easily be retrieved if necessary via the table PK id.

提交回复
热议问题