title: How can I create database table using EF Core at run time?
body: <p>I am new to ASP.NET Core. I am using VS2017 ASP.NET Core with EF Core to build the app that allows me to manage the daily purchase orders which are kept in a table in a database. </p>
  
  <p>On the web there is an input textbox that allows me to enter the table name and when I click the Create button, the new table will be created. I will create a new table every day e.g. "Order25072017", "Order26072017", .. so on.</p>
  
  <p>1) How can I create new table in asp.net Core MVC using EF core programmatically?</p>
  
  <p>Those new tables use the same "Order" model/schema and the code to get the order list is "_context.Order25072017.ToList();". I am planning to create the dropdown with a list of table names. When selected, it will allow me to get the order list from the selected table.</p>
  
  <p>2) What do I need to do in OnModelCreating()? 
  3) How can I change the table name in my query e.g. _context.{newtable}.ToList() at the run time?</p>
  
  <p>The DB Context :</p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options)
          : base(options)
      {
      }
  
      public DbSet&lt;Order&gt; Order25072017 { get; set; }
  
      protected override void OnModelCreating(ModelBuilder builder)
      {
          base.OnModelCreating(builder);
      }
  }
  </code></pre>
  
  <p>The Model :</p>
  
  <pre><code>public class Order
  {
      public int ID { get; set; }
      [Required]
      public string Product  { get; set; }
      public int Price { get; set; }
      public int Discount { get; set; }
  }
  </code></pre>
  
  <p>The constructor in OrderController:</p>
  
  <pre><code>private readonly ApplicationDbContext _context;
  public OrderController(ApplicationDbContext context)
  {
      _context = context;
  }
  </code></pre>