title: Generating database per tenant using EF C#
body: <p>I am building a multi-tenant application using <code>C# EF Code First approach</code>.</p>
  
  <p>I am opting for separate DB per tenant. In this regard, when the application loads the tenant can login or register.</p>
  
  <p>This is how registration page looks like.</p>
  
  <p><a href="https://i.stack.imgur.com/GjD9E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GjD9E.png" alt="enter image description here"></a></p>
  
  <p>On submit, I capture this tenant details in the common DB with name <code>MyAppDB</code> &amp; table <code>tblTenants</code></p>
  
  <p>Here Tenant name is unique &amp; on successful submission of the form, I need to create new DB on the same server with Tenant name &amp; generate set of tables for the Models.</p>
  
  <p>This is my model looks like for every Tenant.</p>
  
  <pre><code>public class Product
  {
     public int Id { get; set;}
  
     public string Name { get; set;}
  }
  
  public class Sales
  {
     public int Id { get; set;}
  
     public string Name { get; set;}
  }
  </code></pre>
  
  <p>How do I generate this Models to tables using C# EF Code First approach??</p>
  
  <p>Thanks.</p>