diff --git a/pyecoregen/ecore.py b/pyecoregen/ecore.py
index <HASH>..<HASH> 100644
--- a/pyecoregen/ecore.py
+++ b/pyecoregen/ecore.py
@@ -93,7 +93,7 @@ class EcorePackageModuleTask(EcoreTask):
 
         attributes = itertools.chain(*(c.eAttributes for c in classes))
         attributes_types = (a.eType for a in attributes)
-        imported |= {t for t in attributes_types if t.ePackage not in {p, ecore.eClass}}
+        imported |= {t for t in attributes_types if t.ePackage not in {p, ecore.eClass, None}}
 
         imported_dict = {}
         for classifier in imported:
Fix generation when attribute's type is not contained in a package

In some cases, attributes' type can be outside a Resource and an
EPackage (when build in memory). In thoses cases, as the EPackage is
'None', the code generation would raise an error.