... if (allEntitiesAttribute != null) { var dbContext = new MyDbContext(); return ((IObjectContextAdapter)dbContext) .ObjectContext .MetadataWorkspace .GetItems<EntityType>(DataSpace.OSpace) .Select(e => Type.GetType(e.FullName)) .Except(allEntitiesAttribute.Except) .Select(entityType => new[] { specimenContext.Resolve(entityType) }) .ToArray(); } ...