src/Shared/EntityFramework/ModelConfiguration/Configuration/ConventionsConfiguration.cs
/// <summary>
///     Enables a configuration convention for the <see cref="DbModelBuilder" />. This convention
///     will run before the one specified.
/// </summary>
/// <typeparam name="TExistingConvention"> The type of the convention before which the enabled one will run. </typeparam>
/// <param name="newConvention"> The convention to enable. </param>
Enables a configuration convention for the . This convention
will run before the one specified.
Enables a configuration convention for the . This convention will run before the one specified .
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
        public void AddBefore<TExistingConvention>(IConvention newConvention)
            where TExistingConvention : IConvention
        {
            Check.NotNull(newConvention, "newConvention");
            var typeMissmatch = true;
            if (ConventionsTypeFilter.IsConfigurationConvention(newConvention.GetType())
                && ConventionsTypeFilter.IsConfigurationConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _configurationConventions);
            }
            if (ConventionsTypeFilter.IsConceptualModelConvention(newConvention.GetType())
                && ConventionsTypeFilter.IsConceptualModelConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _conceptualModelConventions);
            }
            if (ConventionsTypeFilter.IsStoreModelConvention(newConvention.GetType())
                && ConventionsTypeFilter.IsStoreModelConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _storeModelConventions);
            }
            if (ConventionsTypeFilter.IsConceptualToStoreMappingConvention(newConvention.GetType())
                && ConventionsTypeFilter.IsConceptualToStoreMappingConvention(typeof(TExistingConvention)))
            {
                typeMissmatch = false;
                Insert(typeof(TExistingConvention), 0, newConvention, _conceptualToStoreMappingConventions);
            }
            if (typeMissmatch)
            {
                throw new InvalidOperationException(
                    Strings.ConventionsConfiguration_ConventionTypeMissmatch(
                        newConvention.GetType(), typeof(TExistingConvention)));
            }
        }
[ SuppressMessage ( " " , " " ) ] public void AddBefore < TExistingConvention > ( IConvention newConvention ) where TExistingConvention : IConvention { Check . NotNull ( newConvention , " " ) ; var typeMissmatch = true ; if ( ConventionsTypeFilter . IsConfigurationConvention ( newConvention . GetType ( ) ) && ConventionsTypeFilter . IsConfigurationConvention ( typeof ( TExistingConvention ) ) ) { typeMissmatch = false ; Insert ( typeof ( TExistingConvention ) , 0 , newConvention , _configurationConventions ) ; } if ( ConventionsTypeFilter . IsConceptualModelConvention ( newConvention . GetType ( ) ) && ConventionsTypeFilter . IsConceptualModelConvention ( typeof ( TExistingConvention ) ) ) { typeMissmatch = false ; Insert ( typeof ( TExistingConvention ) , 0 , newConvention , _conceptualModelConventions ) ; } if ( ConventionsTypeFilter . IsStoreModelConvention ( newConvention . GetType ( ) ) && ConventionsTypeFilter . IsStoreModelConvention ( typeof ( TExistingConvention ) ) ) { typeMissmatch = false ; Insert ( typeof ( TExistingConvention ) , 0 , newConvention , _storeModelConventions ) ; } if ( ConventionsTypeFilter . IsConceptualToStoreMappingConvention ( newConvention . GetType ( ) ) && ConventionsTypeFilter . IsConceptualToStoreMappingConvention ( typeof ( TExistingConvention ) ) ) { typeMissmatch = false ; Insert ( typeof ( TExistingConvention ) , 0 , newConvention , _conceptualToStoreMappingConventions ) ; } if ( typeMissmatch ) { throw new InvalidOperationException ( Strings . ConventionsConfiguration_ConventionTypeMissmatch ( newConvention . GetType ( ) , typeof ( TExistingConvention ) ) ) ; } }
Enables a configuration convention for the .
Enables a configuration convention for the .
newConvention
IConvention
The convention to enable.
The convention to enable .
typeparam
The type of the convention before which the enabled one will run.
The type of the convention before which the enabled one will run .