When I tried to use arcpy.management.Delete(fc) to delete a feature class from a SDE database, it failed with error message " ERROR 000601: Cannot delete ..\SECore_Tools_Testing_sde.DBO.point_windmill. May be locked by another application. Failed to execute (Delete)."
Then I add the following code before delete the feature class:
edit = arcpy.da.Editor(arcpy.env.workspace)
I got different error message " ERROR 000496: table is being edited. Failed to execute (Delete)."
Please help! Thanks.
If one of the layers you are adding is one you are trying to delete, don't add it and see if you can delete it from the database.
If you are trying to just remove it from the map, then you should be using removeLayer from ...