它在 System.Web.Util.SecUtility 中被调用并且是硬编码的。除非您想重新发明轮子,否则您需要重新配置数据库。我已经做了。不是脑部手术,而是大量的工作,并且在我的书中不符合隔离数据库的兴趣。
internal static void CheckSchemaVersion(ProviderBase provider, SqlConnection connection, string[] features, string version, ref int schemaVersionCheck)
{
if (connection == null)
{
throw new ArgumentNullException("connection");
}
if (features == null)
{
throw new ArgumentNullException("features");
}
if (version == null)
{
throw new ArgumentNullException("version");
}
if (schemaVersionCheck == -1)
{
throw new ProviderException(SR.GetString("Provider_Schema_Version_Not_Match", new object[] { provider.ToString(), version }));
}
if (schemaVersionCheck == 0)
{
lock (provider)
{
if (schemaVersionCheck == -1)
{
throw new ProviderException(SR.GetString("Provider_Schema_Version_Not_Match", new object[] { provider.ToString(), version }));
}
if (schemaVersionCheck == 0)
{
SqlCommand command = null;
SqlParameter parameter = null;
foreach (string str in features)
{
command = new SqlCommand("dbo.aspnet_CheckSchemaVersion", connection);
command.CommandType = CommandType.StoredProcedure;
parameter = new SqlParameter("@Feature", str);
command.Parameters.Add(parameter);
parameter = new SqlParameter("@CompatibleSchemaVersion", version);
command.Parameters.Add(parameter);
parameter = new SqlParameter("@ReturnValue", SqlDbType.Int);
parameter.Direction = ParameterDirection.ReturnValue;
command.Parameters.Add(parameter);
command.ExecuteNonQuery();
if (((parameter.Value != null) ? ((int) parameter.Value) : -1) != 0)
{
schemaVersionCheck = -1;
throw new ProviderException(SR.GetString("Provider_Schema_Version_Not_Match", new object[] { provider.ToString(), version }));
}
}
schemaVersionCheck = 1;
}
}
}
}