Let's say I have a table "foo" that I want to script out using SMO. Is there a way to have it so that in the generated script the table has a different name such as "foo2"?
Database db = sqlServer.Databases["testdb"];
Table foo = db.Tables["foo"];
foo.Name = "foo2";
If I do this, I get this exception when I try to set foo.Name:
"Cannot perform the operation on this object, because the object is a member of a collection."
Is there any way to do this with SMO?