Scope ModelContext to Document, and handle detached documents
#177
+38
−8
ModelContext to Document, and handle detached documents
#177