本文介绍了.NET Standard 2.0中的Microsoft.AspNet.Identity和Microsoft.AspNet.Identity.EntityFramework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我们正在启动的项目由几个共享两个库的解决方案组成。今天,所有内容都用 c兼容

We keep our UserManager shared between the projects. Container is from SimpleInjector which is compatible with .NET Standard 2.0.

public class AppUserManager : UserManager<AppUser>
{

    public AppUserManager(IUserStore<AppUser> store)
        : base(store)
    {

    }

    public static AppUserManager Create<AppContainer>() where AppContainer : Container, new()
    {
        var container = new AppContainer();
        var store = container.GetInstance<IUserStore<AppUser>>();

        var manager = new AppUserManager(store);

        manager.UserValidator = new UserValidator<AppUser>(manager)
        {
            AllowOnlyAlphanumericUserNames = false
        };


        return manager;
    }
}

如果 EntityFramework NuGet 安装在共享库中,出现以下警告。我们不能冒险。

If the EntityFramework NuGet is installed in the shared library the warning below is present. We can't risk that.

我已经了解了为什么他们将 IdentityUser , IdentityUser 与EF非常相关。但是,这使得向 .NET Standard 2.0的移植变得困难。。

I have read about why they put IdentityUser in the EF Library, IdentityUser is very EF specific. However it makes porting to .NET Standard 2.0. harder.

推荐答案

鉴于我们只需要 EntityFramework 6.2.0 即可同时使用 .NET Framework 和 .NET Core ,这将在 .NET Core 3

Given that we only need EntityFramework 6.2.0 to work with both .NET Framework and .NET Core this will be solved in .NET Core 3.

这篇关于.NET Standard 2.0中的Microsoft.AspNet.Identity和Microsoft.AspNet.Identity.EntityFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:26
查看更多