title: Reflection to build list of EntityTypeConfiguration for Entity Framework CPT5
body: <p>I don't want to have to add each mapping class manually to the ModelBuilder() so was trying to use my limited knowledge of reflection to register them. This is what I have, and this is the error I am getting:</p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>private static ModelBuilder CreateBuilder() {
              var contextBuilder = new ModelBuilder();
              IEnumerable&lt;Type&gt; configurationTypes = typeof(DatabaseFactory)
                  .Assembly
                  .GetTypes()
                  .Where(type =&gt; type.IsPublic &amp;&amp; type.IsClass &amp;&amp; !type.IsAbstract &amp;&amp; !type.IsGenericType &amp;&amp; typeof(EntityTypeConfiguration).IsAssignableFrom(type) &amp;&amp; (type.GetConstructor(Type.EmptyTypes) != null));
  
              foreach (var configuration in configurationTypes.Select(type =&gt; (EntityTypeConfiguration)Activator.CreateInstance(type)))
              {
                  contextBuilder.Configurations.Add(configuration);
              }
  
              return contextBuilder;
          }
  </code></pre>
  
  <p><strong>ERROR:</strong>
  Error   2   The type arguments for method 'System.Data.Entity.ModelConfiguration.Configuration.ConfigurationRegistrar.Add(System.Data.Entity.ModelConfiguration.EntityTypeConfiguration)' cannot be inferred from the usage. Try specifying the type arguments explicitly.    C:\root\development\playground\PostHopeProject\PostHope.Infrastructure.DataAccess\DatabaseFactory.cs    67  17  PostHope.Infrastructure.DataAccess</p>