title: SMO scripting entire database like Studio Management does with Generate Scripts
body: <p>I am trying to set up a C# tool that scripts an entire database from the tables down to the stored procedures. I want to get all the schema and data. I am having a hard time finding much on the net on how to do this properly. I would think this would be common practice as an alternative if you don't wish to actually back the dabase up using Backup or Transfer, but I can't find much on the subject. Can anyone direct me to something on how to do this or tell me what needs to be done? I have found how to script Tables and stored procedures, but I want to get EVERYTHING in the database so that I can revert back to where it was if changes to the database breaks other things. </p>
  
  <p>One of the reasons I am going about it this way is because i know that if you do a backup:</p>
  
  <p>a.) it can get corrupt
  b.) you can only do a back up on the server hosting the SQL server. You cannot back it up on your local machine if you are running the application remotely from the SQL Server. This is of course assuming that I cannot always rely on a UNC path or ftp script of any kind.</p>