I added a simple field to a content part
ContentDefinitionManager.AlterPartDefinition("CarouselContentPart", b =>
b
.WithField("AutoPlay", cfg =>
cfg.OfType("NumericField")
.WithSetting("NumericFieldSettings.Hint", "Enter a value in milliseconds for autoplay (leave blank for no autoplay)")
.WithSetting("NumericFieldSettings.Required", "false")
.WithDisplayName("Autoplay"))
);
return 18;
its got added twice and now I can't remove it, either through another migration or through the back office. this is the stack trace
An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back Sequence contains more than one matching element System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable
1 source, Func
2 predicate) at Orchard.ContentManagement.MetaData.Builders.ContentPartDefinitionBuilder.RemoveField(String fieldName) in C:\Development\FE-Corporate\src\Orchard\ContentManagement\MetaData\Builders\ContentPartDefinitionBuilder.cs:line 46 at Orchard.ContentTypes.Services.ContentDefinitionService.<>c__DisplayClass48.b__47(ContentPartDefinitionBuilder typeBuilder) at Orchard.ContentManagement.MetaData.ContentDefinitionManagerExtensions.AlterPartDefinition(IContentDefinitionManager manager, String name, Action1 alteration) in C:\Development\FE-Corporate\src\Orchard\ContentManagement\MetaData\IContentDefinitionManager.cs:line 32 at Orchard.ContentTypes.Services.ContentDefinitionService.RemoveFieldFromPart(String fieldName, String partName) at Orchard.ContentTypes.Controllers.AdminController.RemoveFieldFromPOST(String id) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f()
If you don't have any important data in your new content part yet you can try just dropping and recreating it with a migration.
This will make you lose all the data saved for the content part but will also give you a chance to make a clean break.
You can remove the content part like this: