Exemple #1
0
        /// <summary>
        ///     Fluently configures AutoModelBuilder for Entity Framework for application
        /// </summary>
        /// <param name="optionsBuilder">DbContestOptionsBuilder</param>
        /// <param name="action">AutoModelBuilder</param>
        /// <returns>DbContextOptionsBuilder</returns>
        public static DbContextOptionsBuilder Configure(this DbContextOptionsBuilder optionsBuilder,
                                                        Action <FluentModelBuilderConfiguration> action)
        {
            ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(
                new FluentModelBuilderOptionsExtension());
            var builder = new FluentModelBuilderOptionsBuilder(optionsBuilder);

            builder.Configuration(action);
            return(optionsBuilder);
        }
Exemple #2
0
        /// <summary>
        ///     Fluently configures AutoModelBuilder for Entity Framework for application
        /// </summary>
        /// <param name="optionsBuilder">DbContestOptionsBuilder</param>
        /// <param name="builders">AutoModelBuilders</param>
        /// <returns>DbContextOptionsBuilder</returns>
        public static DbContextOptionsBuilder Configure(this DbContextOptionsBuilder optionsBuilder,
                                                        params AutoModelBuilder[] builders)
        {
            ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(
                new FluentModelBuilderOptionsExtension());
            var builder = new FluentModelBuilderOptionsBuilder(optionsBuilder);

            builder.Configuration(x =>
            {
                foreach (var mBuilder in builders)
                {
                    x.Add(mBuilder);
                }
            });
            return(optionsBuilder);
        }