title: Why It requires the default constructor instead of using my factory method directly?
body: <p>Using <strong>Visual Studio 2017</strong> I have an <strong>ASP.NET Core</strong> MVC application. I registered the necessary method of my factory, because in the model each instance of each my class can be created only through the factory:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddTransient&lt;ITechnicalTask&gt;(_ =&gt;
          // It returns ITechnicalTask instance
          ModelFactory.Current.CreateTechnicalTaskTemplate(
              "Template Name"));
  
      // Add framework services.
      services.AddMvc();
  
  }
  </code></pre>
  
  <p>My controller has such methods:</p>
  
  <pre><code>[HttpGet]
  public IActionResult CreateTemplate() =&gt; View();
  
  [HttpPost]
  public IActionResult CreateTemplate(ITechnicalTask item)
  {    
      repo.Templates.Add(item);
      return View("TemplatesList");
  }
  </code></pre>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form asp-action="CreateTemplate" method="post"&gt;
      &lt;div class="form-group"&gt;
          &lt;label asp-for="TemplateName"&gt;Template name:&lt;/label&gt;
          &lt;input class="form-control" asp-for="TemplateName" /&gt;
      &lt;/div&gt;
      &lt;div class="text-center"&gt;
          &lt;button class="btn btn-primary" type="submit"&gt;
              Accept
          &lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I get exception when I press <code>Accept</code> button:</p>
  
  <blockquote>
    <p>An unhandled exception occurred while processing the request.</p>
    
    <p>InvalidOperationException: Could not create an instance of type
    'PikProject.RobotIRA.ITechnicalTask'. Model bound complex types must
    not be abstract or value types and must have a parameterless
    constructor.</p>
    
    <p>Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexTypeModelBinder.CreateModel(ModelBindingContext
    bindingContext)</p>
  </blockquote>
  
  <p>Why It requires the default constructor? Why it is not enough to use my factory method? </p>
  
  <p><strong>UPD</strong></p>
  
  <p>My <em>business-model</em> is located in other project. All its classes are <code>internal</code>. Only interfaces and couple classes are <code>public</code>. Also it defines <em>the factory</em> interface for creating of necessary instances of the interfaces:</p>
  
  <pre><code>public interface IModelFactory {
  
      IEmployee CreateEmployee(string name,
          string middleName, string surname,
          string post);
  
      IAddress CreateAddress(string country, string region,
              string town, string street, string hoseNumber = "",
              string notes = "");
  
      IApproval CreateApproval(IEmployee employee,
          DateTime? datetime = null);
  
      IApprovalCollection CreateApprovalCollection();
  
      IRequirementsCollection CreateRequirementsCollection();
  
      IRequirement CreateRequirement(RequirementTypes type);
  
      ITechnicalTask CreateTechnicalTaskTemplate(string name);
  
      ITechnicalTask CreateTechnicalTaskDocument(
          string templateName);
  
      ITechnicalTaskCollection CreateTechnicalTaskCollection();
  
      IRepository CreateRepository();
  }
  </code></pre>
  
  <p>The current factory is always accessible through the <code>ModelFactory.Current</code> property of that assembly. So, no classes or constructors which are accessible in my <code>ASP.NET Core MVC</code> project.</p>