public static ModelBuilder UseEntityTypeConfiguration(this ModelBuilder modelBuilder)
        {
            IEnumerable <Type> configurationTypes;
            var assembly = typeof(JoggingTrackerDbContext).GetTypeInfo().Assembly;

            if (!AssemblyTypes.TryGetValue(assembly, out configurationTypes))
            {
                configurationTypes = assembly
                                     .GetExportedTypes()
                                     .Where(p => p.GetTypeInfo().IsClass)
                                     .Where(p => !p.GetTypeInfo().IsAbstract)
                                     .Where(p => p.GetInterfaces()
                                            .Where(i => i.GetTypeInfo().IsGenericType)
                                            .Where(i => i.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration <>))
                                            .Any());

                EntityTypeConfigurationExtender.AssemblyTypes[assembly] = configurationTypes;
            }

            var configurations = configurationTypes.Select(p => Activator.CreateInstance(p));

            foreach (dynamic configuration in configurations)
            {
                EntityTypeConfigurationExtender.ApplyConfiguration(modelBuilder, configuration);
            }

            return(modelBuilder);
        }
        private static ModelBuilder ApplyConfiguration <T>(
            this ModelBuilder modelBuilder,
            IEntityTypeConfiguration <T> configuration)
            where T : class
        {
            var entityType = FindEntityType(configuration.GetType());

            dynamic entityTypeBuilder = EntityTypeConfigurationExtender
                                        .GetEntityMethod()
                                        .MakeGenericMethod(entityType)
                                        .Invoke(modelBuilder, null);

            configuration.Configure(entityTypeBuilder);

            return(modelBuilder);
        }