Skip querying model database for Azure database prototypes. (#2095)

This commit is contained in:
Cory Rivera
2023-06-09 15:12:11 -07:00
committed by GitHub
parent 934df0556a
commit f70710124e

View File

@@ -1739,29 +1739,37 @@ WHERE do.database_id = @DbID
} }
else else
{ {
try if (context.Server.DatabaseEngineType == DatabaseEngineType.SqlAzureDatabase)
{
// Azure instances don't have a model database we can query, so just use the defaults
this.originalState = new DatabaseData(context);
}
else
{ {
try try
{ {
//First try to get the properties, if attempt fails get try
//only the minimal set of properties by setting the DefaultInitFields value to false {
this.originalState = new DatabaseData(context, "model"); //First try to get the properties, if attempt fails get
//only the minimal set of properties by setting the DefaultInitFields value to false
this.originalState = new DatabaseData(context, "model");
}
catch (Exception)
{
//Now try again with the optimized(DefaultInitFields set to false) properties
context.Server.SetDefaultInitFields(typeof(Database), false);
this.originalState = new DatabaseData(context, "model");
//Set the DefaultInitFields to its original value
context.Server.SetDefaultInitFields(typeof(Database), databaseDefaultInitFields);
}
this.originalState.owner = String.Empty;
} }
catch (Exception) catch (Exception)
{ {
//Now try again with the optimized(DefaultInitFields set to false) properties
context.Server.SetDefaultInitFields(typeof(Database), false);
this.originalState = new DatabaseData(context, "model");
//Set the DefaultInitFields to its original value //Set the DefaultInitFields to its original value
context.Server.SetDefaultInitFields(typeof(Database), databaseDefaultInitFields); context.Server.SetDefaultInitFields(typeof(Database), databaseDefaultInitFields);
this.originalState = new DatabaseData(context);
} }
this.originalState.owner = String.Empty;
}
catch (Exception)
{
//Set the DefaultInitFields to its original value
context.Server.SetDefaultInitFields(typeof(Database), databaseDefaultInitFields);
this.originalState = new DatabaseData(context);
} }
// New database should not inherit ReadOnly from model database (Fix TFS 885072) // New database should not inherit ReadOnly from model database (Fix TFS 885072)