在Entity Framework中使用Asp.net Identity无法从程序集'EntityFramework,Version = 6.0加载类型.Schema.IndexAttribute'

Eld*_*dho 7 entity-framework asp.net-identity

public EmployeeDTO AuthenticateEmployee(string username, string password)
{
    try
    {
        var userLogin = UnitOfWork.UserLoginRepository.Get(x => x.UserName == username).FirstOrDefault();

        if (userLogin == null)
            return null;
        else
        {
            var userStore = new UserStore<IdentityUser>();
            var userManager = new UserManager<IdentityUser>(userStore);

            // this throws an error.
            var user = userManager.Find("username", "password");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

结果有误:

无法从程序集'EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.ComponentModel.DataAnnotations.Schema.IndexAttribute'.

我使用的是EF 6.0,Microsoft.AspNet.Identity.EntityFrameworkVer 2.0.

我无法使用EF执行任何操作使用Identity我有什么需要做的,我的EDMX在另一个类库中.我认为这是一个DLL问题.

请帮我使用EF的身份.

我已经通过了Msdn

Jot*_*aBe 13

IndexAttribute是EF 6.1中包含的新功能之一.所以问题是你引用了错误的EF版本(6.0).请参考您项目中的6.1.

查看EF版本历史记录.