All examples I've seen by now for ASP.NET Identity 3.0 use Entity Framework to store user-related data.
我现在看到的所有ASP的例子。NET Identity 3.0使用实体框架存储用户相关数据。
Are there any example which does not use Entity Framework and where ApplicationUser
class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser
?
是否有不使用实体框架的例子,并且ApplicationUser类不是从microsoft.aspnet . identity.entityframe . identityuser类派生出来的?
In ASP.NET Identity 2.x it was needed to implement IUser
interface. It seems there is not such interface now - so we're not sure how to define User
class correctly. There is almost no documentation on this subject.
在ASP。净身份2。需要实现IUser接口。现在似乎没有这样的接口,所以我们不确定如何正确定义User类。几乎没有关于这个主题的文档。
Second problem is with AddIdentity
call in Startup.ConfigureServices
. It's pretty tied to the particular classes from Microsoft.AspNet.Identity.EntityFramework
namespace and it's unclear how to register identity services without those classes.
第二个问题是startup . configure reservices中的额外调用。它与Microsoft.AspNet.Identity中的特定类紧密相关。EntityFramework名称空间,不清楚如何注册没有这些类的标识服务。
2 个解决方案
#1
12
I have implemented it in my project, the main things you have to implement is UserStore and RoleStore
我已经在我的项目中实现了它,您需要实现的主要内容是UserStore和RoleStore
my SiteUser and SiteRole classes do not inherit from anything
我的SiteUser和SiteRole类没有从任何东西继承
the main thing is to add your own services before letting asp.net identity add its own services
主要的事情是在让asp.net标识添加自己的服务之前添加自己的服务
services.TryAdd(ServiceDescriptor.Scoped<IUserStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserPasswordStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserEmailStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserLoginStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserRoleStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserClaimStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserPhoneNumberStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserLockoutStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserTwoFactorStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IRoleStore<SiteRole>, RoleStore<SiteRole>>());
some of the same interfsaces will be registered here but it will use yours if they are registered first
在这里注册的部分是相同的,但如果是先注册的,它会使用你的。
services.AddIdentity<SiteUser, SiteRole>();
#2
2
Are there any example which does not use EntityFramework and where ApplicationUser class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser?
有没有不使用EntityFramework的例子,以及ApplicationUser类不是从microsoft.aspnet . identity.entityframe . identityuser类派生出来的?
Since ASP.NET Identity 3 is part of the .NET Framework 5, which is still unreleased, my guess is you won't find any examples.
因为ASP。NET Identity 3是。NET Framework 5的一部分,它仍然没有发布,我的猜测是您不会找到任何示例。
In ASP.NET Identity 2.x it was needed to implement IUser interface. It seems there is not such interface now - so we're not sure how to define "User" class correctly.There is almost no documentation on this subject.
在ASP。净身份2。需要实现IUser接口。现在似乎还没有这样的接口——所以我们不确定如何正确定义“User”类。几乎没有关于这个主题的文档。
Again, the lack of docs is probably due to the unreleased nature of the software. However just looking at the source code, it seems as though the ApplicationUser can derive from any POCO object -- without the need to implement an IUser<TKey>
interface.
同样,缺少文档可能是由于软件的未发布特性。不过,只要看看源代码,就好像ApplicationUser可以从任何POCO对象中派生出来——而不需要实现IUser
As far as configuring services, have a look at IdentityServiceCollectionExtensions
and IdentityEntityFrameworkBuilderExtensions
. It seems as if the first is in identity core as a means of providing a context within which to register services for application identity, whereas the second is an entityframework-specific implementation using that context.
至于配置服务,请看一下IdentityServiceCollectionExtensions和IdentityEntityFrameworkBuilderExtensions。第一个似乎是在identity core中,作为提供在其中注册应用程序标识服务的上下文的手段,而第二个是使用该上下文的实体框架特定的实现。
The solution for implementing something that uses ASP.NET Identity 3 but not EF seems like it would just be a matter of providing different implementations for the identity service interfaces and then wiring up those dependencies during app configuration. You can use the base EntityFramework implementation as a guide for how to DIY. But caveat emptor, identity 3 could change again before final release, so anything you build against identity 3 now is subject to change.
实现使用ASP的解决方案。NET Identity 3而非EF似乎只是提供标识服务接口的不同实现,然后在应用程序配置期间连接这些依赖项。您可以使用基本的EntityFramework实现作为DIY指南。但是,买者请注意,身份3在最终发布之前可能会再次发生变化,所以您现在针对身份3构建的任何东西都可能发生变化。
#1
12
I have implemented it in my project, the main things you have to implement is UserStore and RoleStore
我已经在我的项目中实现了它,您需要实现的主要内容是UserStore和RoleStore
my SiteUser and SiteRole classes do not inherit from anything
我的SiteUser和SiteRole类没有从任何东西继承
the main thing is to add your own services before letting asp.net identity add its own services
主要的事情是在让asp.net标识添加自己的服务之前添加自己的服务
services.TryAdd(ServiceDescriptor.Scoped<IUserStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserPasswordStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserEmailStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserLoginStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserRoleStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserClaimStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserPhoneNumberStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserLockoutStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IUserTwoFactorStore<SiteUser>, UserStore<SiteUser>>());
services.TryAdd(ServiceDescriptor.Scoped<IRoleStore<SiteRole>, RoleStore<SiteRole>>());
some of the same interfsaces will be registered here but it will use yours if they are registered first
在这里注册的部分是相同的,但如果是先注册的,它会使用你的。
services.AddIdentity<SiteUser, SiteRole>();
#2
2
Are there any example which does not use EntityFramework and where ApplicationUser class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser?
有没有不使用EntityFramework的例子,以及ApplicationUser类不是从microsoft.aspnet . identity.entityframe . identityuser类派生出来的?
Since ASP.NET Identity 3 is part of the .NET Framework 5, which is still unreleased, my guess is you won't find any examples.
因为ASP。NET Identity 3是。NET Framework 5的一部分,它仍然没有发布,我的猜测是您不会找到任何示例。
In ASP.NET Identity 2.x it was needed to implement IUser interface. It seems there is not such interface now - so we're not sure how to define "User" class correctly.There is almost no documentation on this subject.
在ASP。净身份2。需要实现IUser接口。现在似乎还没有这样的接口——所以我们不确定如何正确定义“User”类。几乎没有关于这个主题的文档。
Again, the lack of docs is probably due to the unreleased nature of the software. However just looking at the source code, it seems as though the ApplicationUser can derive from any POCO object -- without the need to implement an IUser<TKey>
interface.
同样,缺少文档可能是由于软件的未发布特性。不过,只要看看源代码,就好像ApplicationUser可以从任何POCO对象中派生出来——而不需要实现IUser
As far as configuring services, have a look at IdentityServiceCollectionExtensions
and IdentityEntityFrameworkBuilderExtensions
. It seems as if the first is in identity core as a means of providing a context within which to register services for application identity, whereas the second is an entityframework-specific implementation using that context.
至于配置服务,请看一下IdentityServiceCollectionExtensions和IdentityEntityFrameworkBuilderExtensions。第一个似乎是在identity core中,作为提供在其中注册应用程序标识服务的上下文的手段,而第二个是使用该上下文的实体框架特定的实现。
The solution for implementing something that uses ASP.NET Identity 3 but not EF seems like it would just be a matter of providing different implementations for the identity service interfaces and then wiring up those dependencies during app configuration. You can use the base EntityFramework implementation as a guide for how to DIY. But caveat emptor, identity 3 could change again before final release, so anything you build against identity 3 now is subject to change.
实现使用ASP的解决方案。NET Identity 3而非EF似乎只是提供标识服务接口的不同实现,然后在应用程序配置期间连接这些依赖项。您可以使用基本的EntityFramework实现作为DIY指南。但是,买者请注意,身份3在最终发布之前可能会再次发生变化,所以您现在针对身份3构建的任何东西都可能发生变化。