O tipo de entidade ApplicationUser não faz parte do modelo para o contexto atual Asp.Net MVC
Abaixo está o código obrigatório para o meu aplicativo. Estou recebendo o erro indicado acima no meu arquivo do controlador de conta. Estou usando o código de registro e login da conta integrado no MVC 4. Não foi possível registrar o usuário. Eu vi o link abaixo no stackoverflow para resolver meu erro, mas não foi possível resolvê-lo
Minhas seqüências de conexão no meu código Web.Config
<connectionStrings>
<add name="PromoteMyNameEntities1" connectionString="metadata=res://*/PromoteDB.csdl|res://*/PromoteDB.,ssdl|res://*/PromoteDB.msl;provider=System.Data.SqlClient;provider connection string="data source=Dell-PC\SQLEXPRESS;initial catalog=PromoteMyName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="DefaultConnection" connectionString="data source=Dell-PC\SQLEXPRESS;initial catalog=PromoteMyName;integrated security=True;" providerName="System.Data.SqlClient" />
<connectionStrings>
Arquivo IdentityModel.cs
using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
namespace PromoteMyName.Models
{
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
Meu arquivo DbContent
public partial class PromoteMyNameEntities1 : DbContext
{
public PromoteMyNameEntities1()
: base("name=PromoteMyNameEntities1")
{
}
AccountController.CS (Obtendo um erro neste arquivo)
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
//Getting Error at Line Below
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
// string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
// var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
return RedirectToAction("BusinessCategory", "ClientBusinesses");
}
AddErrors(result);
}
// If we got this far, something failed, redisplay form
return View(model);
}