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");
}
}
}
Results in error:
Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
I'm using EF 6.0, Microsoft.AspNet.Identity.EntityFramework
Ver 2.0.
I couldn't perform any action based on EF using Identity is there anything I have to do, my EDMX is in another class library. I think its a DLL issue.
Please help me to use identity with EF.
I have gone through Msdn
IndexAttribute
is one of the new things included in EF 6.1. So the problem is that you're referencing the wrong EF version (6.0). Please reference 6.1 in your project.
Look at EF Version History.
I also had this error but all the EntityFramework references in packages.config were pointing to the latest EF version (in my case 6.1.3). I unloaded the offending project where the error was occuring from and noticed the Hint paths for EF were old. After updating them, they worked fine.
Old References:
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
Updated working references:
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>