ASP.NET Core EF6 Identity - asp.net

I am creating a new project in ASP.NET Core with EF6 as the ORM - Note not EF Core.
I am having issues trying to configure the Identity Store.
Here is what I have so far:
Startup.cs
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
This line is causing me the headache. AddEntityFrameworkStores is for EF Core and not the full version of EF 6.
How do I reference the underlying data store for EF6
Thanks

It seems like you have overridden the default data type of Id for ApplicationUser and IdentityRole.
Try AddEntityFrameworkStores<ApplicationDbContext, int>(), or the with type that you have overridden.

Related

What are the steps needed in order to isolate ASP.NET Core Identity inside a .NET Standard Class Library targeting a SQL Server database?

I am currently working on a legacy application and we need to re-implement the Authentication and Authorization part in a separate .NET Standard library using ASP.NET Core Identity.
The starting point and implementation path is not clear for me. I installed the following packages:
Microsoft.AspNetCore.Identity
Microsoft.AspNetCore.Identity.EntityFrameworkCore
I don't know how to configure it to use SQL Server or to run migrations.
I apologize if I'm asking simplistic questions.
Please help if you can.
Thanks in advance
You might want to start by going though some of the tutorials. Introduction to Identity on ASP.NET Core
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
I moved a legacy user database over to asp .net identity recently what i ended up doing was creating the identity tables and then creating a sql script which migrated all of my users over to the new data structure. The only trick was converting the passwords.

.Net Identity 3 on existing solution

I believe that .NET Identity 3 cannot run on an existing (v4.5) ASP.NET solution, but requires .NET Core. I cannot update to .NET Core. Is there a workaround for this? If not then how are people supposed to migrate from ASP.NET Membership to ASP.Net Identity?
First of all, I need to note that ASP.NET Core (which works with Identity 3) does not require .NET Core. It can be used either over .NET Core or .NET Framework 4.6.1 (or higher).
I guess you use the default approach in both cases (Membership and Identity) when all information about users, roles, passwords, etc, is stored in some database.
So, the best way to migrate from Membership to Identity is the following:
create a new ASP.NET Core project using the default template and with "Authentication" turned on
then write a small console program which will move all user-related information from your old membership tables to the new ones (created automatically by ASP.NET Identity)
then move all other your controllers and views one by one.
The only problem here - is that Identity will not recognize the passwords' hashes created with Membership. To resolve it you will need to define your own implementation of IPasswordHasher interface and register it in DI container as it's described in this article.

SharpRepository EfCoreRepository Initialization in .net Core

I need help in initializing SharpRepository in .net Core? How do I use dbcontext with SharpRepository? Where in startup can I put initialization code?
I am using Entityframeworkcore with sql server
https://github.com/SharpRepository/SharpRepository
Please post if you have sample code
Thank you
now EfCore repository is stable!
You need to setup DbContext at the same way microsoft suggest
services.AddDbContext<ContactContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
in ConfigureServices inside Statup.cs
you can find a setup guide https://github.com/SharpRepository/SharpRepository/wiki/Getting-started
a full .net core mvc project sample is here:
https://github.com/SharpRepository/SharpRepository/tree/develop/SharpRepository.Samples.CoreMvc
Regards

ASP.NET MVC5 add authentication into an empty project

I've created an empty asp.net mvc5 project, used EF with code first approach. How can I add OWIN authentication and store Users and Roles in my created database? How can I customize OWIN authentication for my purpose?
Look into Microsoft's Identity framework. You can the Nuget package Identity EntityFramework to your project.
A good guide to setup a token based authentication: http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/

ASP.Net Identity using DevExpress ORM instead of Entity Framework

I'm implementing ASP.Net Identity for my MVC web application.
Could someone profide hints on how to use DevEx ORM and not Entity Framework?
Thanks in advance.
I got this answer from DevEx team:
Hi Muris,
ASP.NET Identity Framework is highly dependable on the Entity Framework, therefore it is required to write a lot of custom code to utilize it with other ORM. What we plan to do in the context of the Add support for VS2013 authentication modes ticket is to support selecting the ASP.NET Identity as an authentication provider when creating a new project using the Project Wizard. Since our Project Wizard uses Entity Framework as a data provider, we will also use it to support the ASP.NET Identity authentication.

Resources