StrataFrame Forum

Two databases in one project

http://forum.strataframe.net/Topic17479.aspx

By Jiri Brazda - 6/30/2008

I have two databases in 1 DDT project. When deploying to SQL server, I receive the following error on second database (the first database is deployed without problems):

X 1.7.2008 9:01:04 -> Creating database 'OHMServerSide' failed.
X 1.7.2008 9:01:04 -> FailedOperationException       
X 1.7.2008 9:01:04 ->   Create failed for Database 'OHMServerSide'.        
X 1.7.2008 9:01:04 -> SmoException       
X 1.7.2008 9:01:04 ->   The PRIMARY filegroup must have at least one file.       
X 1.7.2008 9:01:04 ->        
X 1.7.2008 9:01:04 -> Source     : Microsoft.SqlServer.Smo       
X 1.7.2008 9:01:04 ->        
X 1.7.2008 9:01:04 -> Stack Trace:        
X 1.7.2008 9:01:04 ->    at Microsoft.SqlServer.Management.Smo.FileGroup.ScriptDdl(ScriptingOptions so, StringBuilder ddl, Boolean databaseIsView)       
X 1.7.2008 9:01:04 ->    at Microsoft.SqlServer.Management.Smo.Database.GetFileGroupsScript(StringBuilder query, Boolean databaseIsView, StringCollection emptyfgs, ScriptingOptions so)       
X 1.7.2008 9:01:04 ->    at Microsoft.SqlServer.Management.Smo.Database.ScriptCreate(StringCollection createQuery, ScriptingOptions so)       
X 1.7.2008 9:01:04 ->    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()       
X 1.7.2008 9:01:04 ->    at Microsoft.SqlServer.Management.Smo.Database.Create()       
X 1.7.2008 9:01:04 ->    at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.CreateSmoObject(ICreatable ObjectToCreate, String ObjectName, DBEObjectType ObjectType, Boolean verboseLogging)       
X 1.7.2008 9:01:04 ->        

When I create this database manually (without any content, I just created new empty database in management studio) and tried to deploy it againg, i received the following error:

• 1.7.2008 9:03:25 -> Ensuring Filegroups exist on database 'OHMServerSide'
X 1.7.2008 9:03:25 -> Dropping datafile 'OHMServerSide' failed.
X 1.7.2008 9:03:25 -> FailedOperationException       
X 1.7.2008 9:03:25 ->   Drop failed for DataFile 'OHMServerSide'.        
X 1.7.2008 9:03:25 -> ExecutionFailureException       
X 1.7.2008 9:03:25 ->   An exception occurred while executing a Transact-SQL statement or batch.       
X 1.7.2008 9:03:25 -> SqlException       
X 1.7.2008 9:03:25 ->   The primary data or log file cannot be removed from a database.       
X 1.7.2008 9:03:25 ->        
X 1.7.2008 9:03:25 -> Source     : Microsoft.SqlServer.Smo       
X 1.7.2008 9:03:25 ->        
X 1.7.2008 9:03:25 -> Stack Trace:        
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)       
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)       
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)       
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)       
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)       
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)       
X 1.7.2008 9:03:25 ->    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCollection queries, Boolean includeDbContext)       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImplWorker(Urn& urn)       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImpl()       
X 1.7.2008 9:03:25 ->    at Microsoft.SqlServer.Management.Smo.DatabaseFile.Drop()       
X 1.7.2008 9:03:25 ->    at MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.DropSmoObject(IDroppable ObjectToDrop, String ObjectName, DBEObjectType ObjectType)       
X 1.7.2008 9:03:25 ->        
• 1.7.2008 9:03:25 -> Filegroup verification complete.

However after this error all other items are deployed correctly.

By Trent L. Taylor - 7/1/2008

The first problem I see (which we may need to be sure can't happen within the DDT) is that you have a file group without a data file.  Open up your DDT project, select the PRIMARY file group, and then make sure that you have a data file within that file group.