2016-06-27 70 views
2

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

步骤:

  1. 创建新的 “ASP.NET核心Web应用程序(.NET框架)” 项目。

  2. 添加的NuGet包 “Npgsql的” v3.1.4和 “Npgsql.EntityFrameworkCore.PostgreSQL” 在Startup.cs V1.0.0-RC2-release1

  3. 修改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>(); 
    } 
    
  4. 运行

  5. 抛出异常的调用AddDbContext():

类型“System.TypeLoadException”的异常出现在MyApp.exe将 但在用户代码中没有处理

其他信息:未能加载类型 “Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionExtensions” from assembly'Microsoft.Extensions.DependencyInjection.Abstractions, Version = 1.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60'。

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

回答

5

更新:This has been fixed

这是github上的known issue,它很快就会被修复。

2016年6月29日

FYI 3.1.5超出,靶向.NET核心RTM。 EFCore提供商还不是 ,这将需要再过一两天。