src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/SerializationHelper/MicrosoftDataEntityDesignSerializationHelper.cs
/// <summary>
///     This method removes all of the child elements of the EntityDesignerViewModel.
/// </summary>
This method removes all of the child elements of the EntityDesignerViewModel.
This method removes all of the child elements of the EntityDesignerViewModel .
internal static void ClearModel(EntityDesignerViewModel viewModel)
        {
            if (viewModel.ModelXRef == null
                || viewModel.GetDiagram() == null)
            {
                return;
            }
            using (var t = viewModel.Store.TransactionManager.BeginTransaction("ClearModel", true))
            {
                foreach (var melem in viewModel.ModelXRef.ReferencedViewElements)
                {
                    if (melem is Inheritance)
                    {
                        melem.Delete();
                    }
                }
                foreach (var melem in viewModel.ModelXRef.ReferencedViewElements)
                {
                    if (melem is Association)
                    {
                        melem.Delete();
                    }
                }
                foreach (var melem in viewModel.ModelXRef.ReferencedViewElements)
                {
                    if (melem is EntityType)
                    {
                        melem.Delete();
                    }
                }
                viewModel.ModelXRef.Clear();
                if (t.IsActive)
                {
                    t.Commit();
                }
            }
        }
internal static void ClearModel ( EntityDesignerViewModel viewModel ) { if ( viewModel . ModelXRef == null || viewModel . GetDiagram ( ) == null ) { return ; } using ( var t = viewModel . Store . TransactionManager . BeginTransaction ( " " , true ) ) { foreach ( var melem in viewModel . ModelXRef . ReferencedViewElements ) { if ( melem is Inheritance ) { melem . Delete ( ) ; } } foreach ( var melem in viewModel . ModelXRef . ReferencedViewElements ) { if ( melem is Association ) { melem . Delete ( ) ; } } foreach ( var melem in viewModel . ModelXRef . ReferencedViewElements ) { if ( melem is EntityType ) { melem . Delete ( ) ; } } viewModel . ModelXRef . Clear ( ) ; if ( t . IsActive ) { t . Commit ( ) ; } } }
This method removes all of the child elements of the EntityDesignerViewModel.
This method removes all of the child elements of the EntityDesignerViewModel .
// The assumption is that if ModelXRef is null or we cannot get the diagram, DSL Model is empty // delete inheritance first // delete associations next // delete entities last // clear out the XRef
viewModel
EntityDesignerViewModel