यह प्रश्न विकसित हुआ है इसलिए मैंने शीर्षक अपडेट किया है। पहचान 2 UserManager.Find फेंकता "अमान्य ऑब्जेक्ट नाम 'dbo.ApplicationUser'" त्रुटिपहचान करने के लिए सरल स्मृति को माइग्रेट करना 2.0
मैं SimpleMembership से पहचान 2. को बदलने कर रहा हूँ मैं रूपांतरण स्क्रिप्ट भाग गया और किया है:
यह मूल शीर्षक था पहचान उपयोग के लिए विभिन्न फाइलों को दोहराया। मैं ऐप बना सकता हूं और चला सकता हूं लेकिन जब "अमान्य ऑब्जेक्ट नेम" dbo.AplicationUser '"को लॉगिन करने का प्रयास var उपयोगकर्ता = UserManager.Find (vM.UserName, vM.Password) पर फेंक दिया गया है;
खाता नियंत्रक:
[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 });
}
}
क्यों उपयोगकर्ता प्रबंधक dbo का उपयोग करने की कोशिश कर रहा है [ApplicationUser] (जो मौजूद नहीं है) डीबीओ के बजाय। [AspNetUsers]?
अद्यतन 1: मैं Microsoft.AspNet.Identity.EntityFramework 1.0 और Microsoft.AspNet.Identity.Core 1.0 के लिए डाउनग्रेड और अब मैं एक मिल "अमान्य ऑब्जेक्ट नाम 'dbo.IdentityUser'" त्रुटि जब UserManager.Find कहा जाता है।
अद्यतन 2:
मैं पहचान 2.0 करने के लिए वापस उन्नत किया और बस को देखने के लिए क्या ऊपर का समर्थन होगा और डेटाबेस हटा दिया और कोड के साथ यह पहली बार पुनर्जीवित (सक्षम-प्रवास करते हैं, अद्यतन-डेटाबेस)। के डिफ़ॉल्ट पहचान टेबल जोड़ने के
बजाय:
dbo.ApplicationUser
dbo.IdentityRole
dbo:
AspNetUserRoles
AspNetUsers
AspNetRoles
AspNetClaims
AspNetUserLogins यह इन तालिकाओं जोड़ा IdentityUserClaim
dbo.I dentityUserLogin
dbo.IdentityUserRole
जो यह बताएगा कि यह एप्लिकेशन यूज़र की तलाश क्यों कर रहा है। मेरे कॉन्फ़िगरेशन के बारे में क्या है जो मानक पहचान नामों के बजाय उन नामों को मजबूर कर रहा है? मैं शायद उन माइग्रेशन स्क्रिप्ट को उन नामों में बदल सकता हूं लेकिन फिर मैं गैर-मानक टेबल नामों के साथ समाप्त हो जाऊंगा जो केवल आगे बढ़ने के लिए भ्रम पैदा करेंगे। डिफ़ॉल्ट पहचान तालिका नाम प्राप्त करने के लिए मैं चीजों को कैसे कॉन्फ़िगर कर सकता हूं?