简体   繁体   中英

TypeLoadException using PostgreSQL with ASP.NET Core Identity

I am attempting to use PostgreSQL as the data store for user authentication in an ASP.NET Core 1.0 Visual Studio 2015 project following installation of VS2015 Update 3 and the Core 1.0 release.

Steps:

  1. Create new "ASP.NET Core Web Application (.NET Framework)" project.

  2. Add NuGet packages "Npgsql" v3.1.4 and "Npgsql.EntityFrameworkCore.PostgreSQL" v1.0.0-rc2-release1

  3. Modify ConfigureServices() in Startup.cs as follows:

     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. Run

  5. Exception thrown on call to AddDbContext():

An exception of type 'System.TypeLoadException' occurred in MyApp.exe but was not handled in user code

Additional information: Could not load type 'Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionExtensions' from assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

I assume this is a compatibility issue that will soon be addressed in Npgsql.EntityFrameworkCore.PostgreSQL, but wanted to confirm this and determine if a workaround is available.

UPDATE: This has been fixed .

This is a known issue on github, it will be fixed soon.

6/29/2016

FYI 3.1.5 is out, targeting .NET Core RTM. The EFCore provider isn't out yet, that will take another day or two.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM