I'm struggling with a very basic problem. it seems though, it's a problem with arcpy itself.

I'm running the following code and it's give me a problem  in the line of:

    with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:

What it says  it cannot open the file "main_points" that is in the database. However if I remove the line of adding field:

    arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)

It runs the script smoothly.

Here is my whole code:


    import arcpy
    WorkingDirectory = r"C:\Users\me\Documents"
    
    arcpy.env.workspace = WorkingDirectory
    arcpy.env.overwriteOutput=True
    arcpy.CreateFileGDB_management(WorkingDirectory, "project.gdb")
    arcpy.FeatureClassToGeodatabase_conversion(["main_points.shp"], "project.gdb")
    arcpy.env.workspace = "project.gdb"
    main_points = arcpy.ListFeatureClasses()[0]
    arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
    with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
        for row in cursor:
            print(row[0]) # just simple printing of Object ID
            cursor.updateRow(row)



How could I overcome this problem?
Thank you in advance.