How to Delete (lots of) Properties?




How can I delete properties directly in SQL? 

I know you can delete properties via the EPiServer CMS by going to EPiServer CMS -> Admin Mode -> Page Type Tab -> Select Page Type -> Select Property -> Delete. But... I want to delete 6 properties, which occur on circa 50 page types, which means a lot of clicking, waiting, and clicking again.  

I hope some has experience with deleting properties 'manually', and want to share their experience :-)


Best, Leonard

#65427 Jan 29, 2013 17:48
  • David Knipe
    Member since: 2008

    Hello Leonard

    I would not advise trying to delete properties directly in SQL, I would advise using the API. Something like the following (I wrote this in comment so cannot guarantee this will work):

    //Get all the pageTypes
    foreach (var pagetype in PageType.List())
      // Loop through all properties
      foreach (var pageDefinition in pagetype.Definitions)
        if (pageDefinition.Name == "PropertyName")



    #65431 Jan 29, 2013 21:02
  • Petter Klang
    Member since: 2008

    As David said doing it in SQL isn't a prefered way but if your a lone cowboy and want to take the road less travelled I would advice to having sql profiler running and then delete a property in adminmode. This will give you the sp:s used for the command.

    Oh.. and yea.. you know.. take a backup =)

    #65441 Edited, Jan 30, 2013 10:20

    Thanks your replies! 

    David, I took your advice and deleted the properties with the API. Your code run flawless! 


    #65466 Jan 30, 2013 14:12