public ActionResult CreateLogin(FormCollection form, TenantLoginViewModel model)
        {
            //todo: implement role for users!  Please design the architecture first!!!
            var tenantDb = new TenantRegistryEntities();
            var tenant = new Tenant
            {
                id = System.Guid.NewGuid().ToString(),
                Name = model.Tenant.Name,
                db = System.Web.Configuration.WebConfigurationManager.AppSettings["NewTenantDatabaseName"],  // todo: Default Tenant db must be get from a separate class
                ConnectionStringName = System.Web.Configuration.WebConfigurationManager.AppSettings["NewTenantConnectionString"] // todo: Tenant connection string must be get from a separate class
            };

            var userprofile = new UserProfile
            {
                Username = model.UserProfile.Username,
                FirstName = model.UserProfile.FirstName,
                LastName = model.UserProfile.LastName
            };

            // Save tenant
            tenant.UserProfiles.Add(userprofile);
            tenantDb.Tenants.AddObject(tenant);
            tenantDb.SaveChanges();

            // Create asp.net login
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                var pw = form["Password"].ToString();
                var email = form["Email"].ToString();
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserProfile.Username, pw, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    //FormsService.SignIn(model.UserProfile.Username, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            return View("Index");
        }
 /// <summary>
 /// Create a new Tenant object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="db">Initial value of the db property.</param>
 /// <param name="connectionStringName">Initial value of the ConnectionStringName property.</param>
 public static Tenant CreateTenant(global::System.String id, global::System.String name, global::System.String db, global::System.String connectionStringName)
 {
     Tenant tenant = new Tenant();
     tenant.id = id;
     tenant.Name = name;
     tenant.db = db;
     tenant.ConnectionStringName = connectionStringName;
     return tenant;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Tenants EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTenants(Tenant tenant)
 {
     base.AddObject("Tenants", tenant);
 }