Exemplo n.º 1
0
 /// <summary>
 ///     <para>
 ///         Prevents conventions from being executed immediately when a metadata aspect is modified. All the delayed conventions
 ///         will be executed after the returned object is disposed.
 ///     </para>
 ///     <para>
 ///         This is useful when performing multiple operations that depend on each other.
 ///     </para>
 /// </summary>
 /// <returns> An object that should be disposed to execute the delayed conventions. </returns>
 public virtual IConventionBatch DelayConventions() => _dispatcher.DelayConventions();
            public IConventionModelBuilder OnModelFinalized([NotNull] IConventionModelBuilder modelBuilder)
            {
                _modelBuilderConventionContext.ResetState(modelBuilder);
                foreach (var modelConvention in _conventionSet.ModelFinalizedConventions)
                {
                    // Execute each convention in a separate batch so model validation will get an up-to-date model
                    using (_dispatcher.DelayConventions())
                    {
                        modelConvention.ProcessModelFinalized(modelBuilder, _modelBuilderConventionContext);
                        if (_modelBuilderConventionContext.ShouldStopProcessing())
                        {
                            return(_modelBuilderConventionContext.Result);
                        }
                    }
                }

                return(modelBuilder);
            }