使用带有ASP.NET核心标识的PostgreSQL的TypeLoadException

Pan*_*ake 2 .net asp.net postgresql asp.net-mvc npgsql

在安装VS2015 Update 3和Core 1.0版本之后,我试图在ASP.NET Core 1.0 Visual Studio 2015项目中使用PostgreSQL作为用户身份验证的数据存储.

脚步:

  1. 创建新的"ASP.NET核心Web应用程序(.NET Framework)"项目.

  2. 添加NuGet包"Npgsql"v3.1.4和"Npgsql.EntityFrameworkCore.PostgreSQL"v1.0.0-rc2-release1

  3. 修改Startup.cs中的ConfigureServices(),如下所示:

    public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddEntityFrameworkNpgsql()
            .AddDbContext<ApplicationDbContext>(options =>
            options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));
    
        services.AddIdentity<ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();
    
        services.AddMvc();
    
        // Add application services.
        services.AddTransient<IEmailSender, AuthMessageSender>();
        services.AddTransient<ISmsSender, AuthMessageSender>();
    }
    
    Run Code Online (Sandbox Code Playgroud)
  4. 调用AddDbContext()时抛出异常:

MyApp.exe中出现"System.TypeLoadException"类型的异常,但未在用户代码中处理

附加信息:无法从程序集"Microsoft.Extensions.DependencyInjection.Abstractions,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60"加载"Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionExtensions"类型.

我认为这是一个兼容性问题,很快将在Npgsql.EntityFrameworkCore.PostgreSQL中解决,但想确认这一点,并确定是否有可用的解决方法.

Nic*_*sta 5

更新: 这已得到修复.

这是github上的已知问题,很快就会修复.

2016年6月29日

仅供参考3.1.5,面向.NET Core RTM.EFCore提供商还没有出来,这还需要一两天.