相关疑难解决方法(0)

ASP.NET身份DbContext混淆

默认的MVC 5 App附带了IdentityModels.cs中的这段代码 - 这段代码用于默认模板的所有ASP.NET Identity操作:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("DefaultConnection")
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我使用带有Entity Framework的视图构建一个新控制器并在对话框中创建一个"新数据上下文...",我会为我生成这个:

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace WebApplication1.Models
{
    public class AllTheOtherStuffDbContext : DbContext
    {
        // You can add custom code to this file. Changes will not be overwritten.
        // 
        // If you want Entity Framework to drop and regenerate your database
        // automatically whenever you change your model schema, please use data migrations.
        // …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc entity-framework asp.net-mvc-5 asp.net-identity

185
推荐指数
4
解决办法
11万
查看次数