问题
For reasons that I would not like to discuss, our master database schema is currently only in SQL Azure. We are working on bringing it down locally using a tool like Enzo Backup (we're waiting on their developers to fix some bugs we got when attempting to download), but in the meantime, I would like to generate a Linq-to-Sql ORM mapping from the SQL Azure DB schema. When I attempt to do this, the output generates a bunch of error messages like this:
Warning : SQM1012: Unable to extract table 'dbo.[TableName]' from SqlServer. Invalid object name 'syscomments'.
Is it at all possible to generate ORM mapping from a SQL Azure database?
Edit
Note that Generate Scripts from SSMS doesn't work, even in the newest version (2008 R2). You get the following error in the generated report when you try to generate scripts on a SQL Azure database instance, and it fails before processing even the first object:
System.IndexOutOfRangeException: Index was outside the bounds of the array. at Microsoft.SqlServer.Management.SqlScriptPublish.GeneratePublishPage.worker_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
Edit 2
I just attempted to use the free SMOscript tool, and it generates the same kind of error message:
Objects in database [DatabaseName] on server [ServerAddress]:
Error: Index was outside the bounds of the array.
So it looks so far like easily generating DDL scripts is out of the question, and it's broken at the SMO level for 2008 R2 against a SQL Azure DB.
回答1:
Looks like everything tracks back to SMO. I finally got 2008 R2 SP1 installed and working on my computer, and it looks like I'll be able to generate scripts correctly (finally). Thanks for all your help everyone!
来源:https://stackoverflow.com/questions/9622688/use-sqlmetal-on-sql-azure-database