繁体   English   中英

使用Visual Studio 2013模板并带有Asp.Net Identity的代码优先无法正常工作吗?

[英]Code First using Visual Studio 2013 Template with Asp.Net Identity not working?

我正在本教程中使用Code First更新我的AspNetUsers表。

http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx

这是我的IdentityModelClass:

using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Data.Entity;

namespace MTGWeb.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 String Pais;
        public String Email;
        public DateTime UltimoLogin;
        public DateTime FechaRegistro;
        public String Tipo;
        public Boolean Activado;

    }

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("DefaultConnection")
        {
        }

    }
}

我已经执行了以下步骤:

  • 启用任务-确定
  • 添加迁移“ BlaBla ..”
  • 更新数据库

此步骤正确执行(不会因错误而停止),但不会更改任何内容。 我按照本教程的所有步骤操作,使用了自定义数据,并且调试了数据后,这些数据在各个视图模型之间都可以正常发送,但是数据库是问题所在。

我看到了表AspNetUsers,并且没有保存任何字段。 有任何想法吗? 我可以注册用户,但只能保存默认数据( Id, Username, PasswordHash,SecurityStamp and Discriminator

实体框架将属性映射到列。 现在,它们是字段。 像这样将它们更改为自动属性...

public class ApplicationUser : IdentityUser
{
    public String Pais { get; set; }
    public String Email { get; set; }
    public DateTime UltimoLogin { get; set; }
    public DateTime FechaRegistro { get; set; }
    public String Tipo { get; set; }
    public Boolean Activado { get; set; }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM