protected override DataProviderBase InvalidateDataProviderInternal(DataProviderBase dataProvider, string configuration, string connectionString)
        {
            Type type = DefaultProviderType;

            try
            {
                int?configVersion      = GetVersionFromConfiguration(configuration);
                int?serverVersion      = null;
                int?compatibilityLevel = null;
                int?targetVersion      = null;

                using (var connection = (SqlConnection)dataProvider.CreateConnectionObject())
                {
                    connection.ConnectionString = connectionString;
                    connection.Open();

                    serverVersion = GetVersionFromConnection(connection);
                    if (serverVersion >= Sql2005)
                    {
                        compatibilityLevel = GetDatabaseCompatibilityLevel(connection);
                    }
                }

                targetVersion = compatibilityLevel ?? configVersion ?? serverVersion;

                if (targetVersion >= Sql2012)
                {
                    type = typeof(Sql2012DataProvider);
                }
                else if (targetVersion == Sql2008)
                {
                    type = typeof(Sql2008DataProvider);
                }
                else if (targetVersion == Sql2005)
                {
                    type = typeof(Sql2005DataProvider);
                }
                else if (targetVersion == Sql2000)
                {
                    type = typeof(Sql2000DataProvider);
                }
            }
            catch
            {
                return(null);
            }

            return(GetProviderByType(type));
        }
		protected override DataProviderBase InvalidateDataProviderInternal(DataProviderBase dataProvider, string configuration, string connectionString)
		{
			Type type = DefaultProviderType;
			try
			{
				int? configVersion      = GetVersionFromConfiguration(configuration);
				int? serverVersion      = null;
				int? compatibilityLevel = null;
				int? targetVersion      = null;

				using (var connection = (SqlConnection) dataProvider.CreateConnectionObject())
				{
					connection.ConnectionString = connectionString;
					connection.Open();

					serverVersion = GetVersionFromConnection(connection);
					if (serverVersion >= Sql2005)
						compatibilityLevel = GetDatabaseCompatibilityLevel(connection);

				}

				targetVersion = compatibilityLevel ?? configVersion ?? serverVersion;

				if (targetVersion >= Sql2012)
					type = typeof(Sql2012DataProvider);
				else if (targetVersion == Sql2008)
					type = typeof(Sql2008DataProvider);
				else if (targetVersion == Sql2005)
					type = typeof(Sql2005DataProvider);
				else if (targetVersion == Sql2000)
					type = typeof(Sql2000DataProvider);
				
			}
			catch
			{
				return null;
			}

			return GetProviderByType(type);
		}