Skip to main content

Clean up project files

To clean up a project, use the CleanUpProject method of the IWorkspace object. Cleanup deletes the following inconsistent data in the current project:

  • Models with no parent model
  • Associations with no origin
  • Models with no definition in the metamodel

Data for deleted models and editors is also deleted.

public void CleanUpProject(ICommandContext c, ICommandParams p) 
{
var project = c.App.Workspace.CurrentProject;
if (project.Path == null || project.IsDirty)
{
Output.WriteLine("sample", "You must save the project to perform a cleanup.");
return;
}

c.App.Workspace.CleanUpProject(project);
c.App.Output.WriteLine("sample", "Cleanup completed.");
}
Note

When you run a cleanup, the project file and model unit files will be automatically overwritten after the data is deleted.