public virtual void UiBtnCommandAction(Object param) { if (SelectedCodeElement == null) { UiCommandButtonClicked.DoNotify(this); } else { CodeClass cc = SelectedCodeElement.CodeElementRef as CodeClass; if (cc == null) { return; } CodeFunction cf = cc.AddMethodHelper("OnModelCreating", vsCMFunction.vsCMFunctionFunction, vsCMTypeRef.vsCMTypeRefVoid, vsCMAccess.vsCMAccessDefault); if (cf == null) { return; } string modelBuilderType = "System.Data.Entity.DbModelBuilder"; if (cc.IsDerivedFrom["Microsoft.EntityFrameworkCore.DbContext"]) { modelBuilderType = "Microsoft.EntityFrameworkCore.ModelBuilder"; } cf.AddParameter("modelBuilder", modelBuilderType, null); EditPoint editPoint = cf.StartPoint.CreateEditPoint(); editPoint.Insert("protected override "); if (cc.ProjectItem != null) { if (cc.ProjectItem.IsDirty) { cc.ProjectItem.Save(); } } DoAnaliseDbContext(); //foreach(CodeElement ce in cf.Children) //{ // string nm = ce.FullName; // vsCMElement kind = ce.Kind; // if (nm == "") nm = null; //} //DoAnaliseDbContext(); //editPoint = cf.EndPoint.CreateEditPoint(); //editPoint.CharLeft(1); //editPoint.Insert("\n\r int i = 0; \n\r"); //editPoint.SmartFormat(cf.StartPoint); } }