Microsoft.AspNet.Identity.IUser的自定义实现

时间:2022-02-01 02:10:54

I don't like the Code-First-approach and want to make use of the new Identity-Features with my EF-mapped classes. I've got a table User with the columns

我不喜欢Code-First-approach,并希望在我的EF映射类中使用新的Identity-Features。我有一个用户列表

  • Id (bigint, ai, pk)
  • Id(bigint,ai,pk)
  • Login (nvarchar)
  • 登录(nvarchar)
  • Password (nvarchar)
  • 密码(nvarchar)

The Interface Microsoft.AspNet.Identity.IUser enforces 2 properties:

接口Microsoft.AspNet.Identity.IUser强制实施2个属性:

  • Id (string)
  • Id(字符串)
  • UserName (string)
  • 用户名(字符串)

What, if I don't want to use this structure but I also want to do identity the right way?

什么,如果我不想使用这种结构,但我也想以正确的方式做身份?

1 个解决方案

#1


1  

I found out that starting with ASP.NET Identity 2 (still in prerelease) you can do:

我发现从ASP.NET身份2开始(仍然在预发行版中)你可以这样做:

public class MyUser : IdentityUser<long>

Its a little bit more than that when it comes to real life. I blogged about it at codingfreaks (German) and added an English Screencast at Youtube. You can find some good hints here.

它比现实生活中的要多一点。我在codingfreaks(德语)上发表了关于它的博客,并在Youtube上添加了英语截屏视频。你可以在这里找到一些好的提示。

So, it is possible.

所以,这是可能的。

#1


1  

I found out that starting with ASP.NET Identity 2 (still in prerelease) you can do:

我发现从ASP.NET身份2开始(仍然在预发行版中)你可以这样做:

public class MyUser : IdentityUser<long>

Its a little bit more than that when it comes to real life. I blogged about it at codingfreaks (German) and added an English Screencast at Youtube. You can find some good hints here.

它比现实生活中的要多一点。我在codingfreaks(德语)上发表了关于它的博客,并在Youtube上添加了英语截屏视频。你可以在这里找到一些好的提示。

So, it is possible.

所以,这是可能的。