2016-06-27 71 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提供商還不是 ,這將需要再過一兩天。