public SiteRepository() { _db = new SiteContext(); // RelationデータをProxyを作成せずに管理する。 // だからIncludeが必須。 // Attachはうまくいく!! ((IObjectContextAdapter)_db).ObjectContext.ContextOptions.ProxyCreationEnabled = false; }
protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (_db != null) { if (_db.Database.Connection.State != ConnectionState.Closed) _db.Database.Connection.Close(); _db.Dispose(); _db = null; } } }