@@ -55,6 +55,7 @@ public static void Run(string[] args)
55
55
builder . InitialCatalog = DB_Master ;
56
56
using ( SqlConnection conn = new SqlConnection ( builder . ConnectionString ) )
57
57
{
58
+ Console . WriteLine ( $ "Connecting to { builder . DataSource } ") ;
58
59
SqlServer . Management . Smo . Server server = new SqlServer . Management . Smo . Server ( new ServerConnection ( conn ) ) ;
59
60
ServerConnection context = server . ConnectionContext ;
60
61
@@ -102,7 +103,7 @@ public static void Run(string[] args)
102
103
}
103
104
catch ( Exception e )
104
105
{
105
- throw new Exception ( $ "{ args [ 0 ] } execution failed with Error: { e . Message } ") ;
106
+ throw new Exception ( $ "{ args [ 0 ] } execution failed with Error: { e } ") ;
106
107
}
107
108
}
108
109
@@ -158,14 +159,15 @@ private static void UpdateConfig(string key, SqlConnectionStringBuilder builder)
158
159
159
160
private static void DropIfExistsDatabase ( string dbName , ServerConnection context )
160
161
{
162
+ Console . WriteLine ( $ "Dropping database [{ dbName } ] if it exists") ;
161
163
try
162
164
{
163
165
string dropScript = $ "IF EXISTS (select * from sys.databases where name = '{ dbName } ') BEGIN DROP DATABASE [{ dbName } ] END;";
164
166
context . ExecuteNonQuery ( dropScript ) ;
165
167
}
166
168
catch ( ExecutionFailureException ex )
167
169
{
168
- Console . WriteLine ( $ "FAILED to drop database '{ dbName } '. Error message: { ex . Message } ") ;
170
+ Console . WriteLine ( $ "FAILED to drop database '{ dbName } '. Error message: { ex } ") ;
169
171
}
170
172
}
171
173
@@ -174,6 +176,7 @@ private static void CreateDatabase(string dbName, ServerConnection context)
174
176
DropIfExistsDatabase ( dbName , context ) ;
175
177
string createScript = File . ReadAllText ( NorthWindScriptPath ) ;
176
178
179
+ Console . WriteLine ( $ "Creating database [{ dbName } ]") ;
177
180
try
178
181
{
179
182
createScript = createScript . Replace ( DB_Northwind , dbName ) ;
@@ -183,7 +186,7 @@ private static void CreateDatabase(string dbName, ServerConnection context)
183
186
}
184
187
catch ( ExecutionFailureException ex )
185
188
{
186
- Console . WriteLine ( ex . Message ) ;
189
+ Console . WriteLine ( ex ) ;
187
190
throw ;
188
191
}
189
192
}
0 commit comments