我正在使用实体框架。
我将对象保存在 MS_library 缓存管理器中。
但是我现在遇到一个问题:当我从缓存中检索这个对象时
它的 ContextObj 已经被释放。
如何在不将每个实体映射到我的模型对象的情况下解决此问题?
public partial class MaMDBEntities : DbContext
{
public MaMDBEntities()
: base("name=MaMDBEntities")
{
ObjectContext.
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<App> Apps { get; set; }
public DbSet<AppsData> AppsDatas { get; set; }
public DbSet<Browser> Browsers { get; set; }
public DbSet<BrowserVersion> BrowserVersions { get; set; }
public DbSet<BrowserVerToCriteria> BrowserVerToCriterias { get; set; }
public DbSet<CommonConfig> CommonConfigs { get; set; }
public DbSet<Country> Countries { get; set; }
public DbSet<Criterion> Criteria { get; set; }
public DbSet<CTID> CTIDS { get; set; }
public DbSet<DatabaseLastUpdate> DatabaseLastUpdates { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<MamConfiguration> MamConfigurations { get; set; }
public DbSet<MamConfigurationCTID> MamConfigurationCTIDs { get; set; }
public DbSet<MamConfigurationStatus> MamConfigurationStatuses { get; set; }
public DbSet<Pair> Pairs { get; set; }
public DbSet<SettingsServicesConfig> SettingsServicesConfigs { get; set; }
public DbSet<sysdiagram> sysdiagrams { get; set; }
public DbSet<CtidPgPastExistence> CtidPgPastExistences { get; set; }
public virtual ObjectResult<usp_AppsData_GetAll_Result> usp_AppsData_GetAll()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<usp_AppsData_GetAll_Result>("usp_AppsData_GetAll");
}
}