Bu soru gelişti, böylece başlığı güncelleştirdim. 2 UserManager.Find "Geçersiz nesne adı 'dbo.ApplicationUser'" hatasıSimpleMembership'i Kimlik 2.0'a Taşıma
Ben dönüşüm senaryoyu koştu ve ettik Kimlik 2. SimpleMembership dönüştürme ediyorum atar Kimlik:
Bu
orijinal başlık oldu Kimlik kullanımı için çeşitli dosyaları yeniden oluşturdu. Uygulamayı oluşturabilir ve çalıştırabilirim ancak "Geçersiz nesne adı 'dbo.ApplicationUser'" girişimi yapılmaya çalışıldığında var kullanıcıya = UserManager.Find (vM.UserName, vM.Password);Hesap Denetleyici:
[RequireHttps]
[Authorize]
public class AccountController : Controller
{
private readonly IUserService _userService;
public UserManager<ApplicationUser> UserManager { get; private set; }
public AccountController()
: this(new UserService(), new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new MyDb()))) { }
public AccountController(IUserService userService, UserManager<ApplicationUser> userManager)
{ _userService = userService; UserManager = userManager; }
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login() { return View(); }
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginVm vM)
{
if (ModelState.IsValid)
{
var user = UserManager.Find(vM.UserName, vM.Password);
if (user != null)
{
FormsAuthentication.SetAuthCookie(user.UserName, false);
return RedirectToAction("Index", "Home");
}
}
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(vM);
}
ApplicationUser:
public class ApplicationUser : IdentityUser
{
[StringLength(15)]
public new string UserName { get; set; }
public int AcId { get; set; }
public int LcId { get; set; }
public string ConfirmationToken { get; set; }
public bool IsConfirmed { get; set; }
public string PasswordResetToken { get; set; }
}
DBContext.
public class MyDb : IdentityDbContext<ApplicationUser> // DbContext
{
public MyDb() : base("MyApplicaiton") { }
// public virtual DbSet<UserProfiles> Users { get; set; }
public virtual DbSet<MyTable> MyTables { get; set; } // properties marked virtual for Mocking override
...
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<IdentityUserLogin>().HasKey<string>(l => l.UserId);
modelBuilder.Entity<IdentityRole>().HasKey<string>(r => r.Id);
modelBuilder.Entity<IdentityUserRole>().HasKey(r => new { r.RoleId, r.UserId });
}
}
Neden kullanıcı yöneticisi Dbo erişmeye çalışıyor [ApplicationUser] (yok) dbo yerine [AspNetUsers]?
GÜNCELLEME 1: Ben Microsoft.AspNet.Identity.EntityFramework 1.0 ve Microsoft.AspNet.Identity.Core 1.0 döndürüldüğünü ve şimdi bir olsun "Geçersiz nesne adı 'dbo.IdentityUser'" hata UserManager.Find denir.
GÜNCELLEME 2:
Ben Kimlik 2.0'a geri yükseltilmiş ve sadece yedeklenmiş ne olacağını görmek için ve veritabanı silinir ve ilk kodla (enable-göçler, güncelleme-veritabanı) o rejenere.
yerine varsayılan Kimlik tabloları ekleyerek:
dbo.IdentityRole
Dbo
dbo.ApplicationUser:
AspNetUserRoles
AspNetUsers
AspNetRoles
AspNetClaims
AspNetUserLogins Bu tabloları eklendi .IdentityUserClaim
dbo.I dentityUserLogin
dbo.IdentityUserRole
Neden ApplicationUser aradığını açıklar. Standart Kimlik adları yerine bu adları zorlayan yapılandırmamla ilgili nedir? Muhtemelen göçmenlik senaryosunu bu isimlere değiştirebilirdim, ancak daha sonra ileriye doğru karışıklığa yol açacak standart olmayan tablo isimleriyle sonuçlanacağım. Varsayılan Kimlik tablosu adlarını almak için işleri nasıl yapılandırabilirim?