OK. I found a solution:
Server srv = new Server(new ServerConnection("SERVER", "USERID", "PASSWORD"));
srv.SetDefaultInitFields(typeof(Table), true);
Database db = srv.Databases[database];
ScriptingOptions so = new ScriptingOptions();
so.AllowSystemObjects = false;
var dt = db.EnumObjects(DatabaseObjectTypes.Table);
var urns = new Microsoft.SqlServer.Management.Sdk.Sfc.Urn[dt.Rows.Count];
for (int rowIndex = 0; rowIndex < dt.Rows.Count; ++rowIndex)
{
urns[rowIndex] = dt.Rows[rowIndex]["urn"].ToString();
}
var scripter = new Scripter(srv);
var scripts = scripter.Script(urns);
foreach (var script in scripts)
{
System.Diagnostics.Trace.WriteLine(script);
}
it is necessary to script all objects at once.