IdentityServer / IdentityServer3.EntityFramework

EntityFramework persistence layer for IdentityServer3
Apache License 2.0
68 stars 97 forks source link

Dependency on Automapper 4.2.0 problematic #104

Closed MrXemiu closed 8 years ago

MrXemiu commented 8 years ago

Several other IdentityServer3-related projects such as IdentityServer3.Admin.EntityFramework have dependencies on Automapper 4.2.1. The problem is that if the higher version is used, code first seed methods for IdentityServer3.Core models fail.

When I downgrade the Automapper version to 4.2.0, the nuget package manager automatically downgrades IdentityServer3.Admin.EntityFramework from 1.0.0-beta7 to 1.0.0-beta6 which is incompatible with IdentityServer3.Admin 1.0.0-beta8.

I've tried using assembly binding redirects, but either IdentityServer3.EntityFramework dependency requires a specific version or migrate.exe doesn't honor the web.config binding redirects. I'm not sure which.

2016-05-18 11_32_43-windows powershell admin

brockallen commented 8 years ago

Are you using IdentityServer as a NuGet or from source code?

MrXemiu commented 8 years ago

I'm using all IdentityServer components as NuGet packages. This is an excerpt from my packages.config (note the AutoMapper version):

<package id="AutoMapper" version="4.2.1" targetFramework="net452" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="IdentityManager" version="1.0.0-beta5-5" targetFramework="net452" />
<package id="IdentityManager.AspNetIdentity" version="1.0.0-beta5-1" targetFramework="net452" />
<package id="IdentityModel" version="1.11.0" targetFramework="net452" />
<package id="IdentityServer3" version="2.5.0" targetFramework="net452" />
<package id="IdentityServer3.Admin" version="1.0.0-beta8" targetFramework="net452" />
<package id="IdentityServer3.Admin.EntityFramework" version="1.0.0-beta7" targetFramework="net452" />
<package id="IdentityServer3.AspNetIdentity.dll" version="2.0.0" targetFramework="net452" />
<package id="IdentityServer3.EntityFramework" version="2.5.0" targetFramework="net452" />

As configured, the app runs without any dependency errors. If I try to execute a migration such as the following, I get the AutoMapper version exception:

internal sealed class Configuration : DbMigrationsConfiguration<ClientConfigurationDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            MigrationsDirectory = @"Migrations\ClientConfiguration";
        }

        protected override void Seed(ClientConfigurationDbContext context)
        {
            foreach (var client in Clients.Get)
            {
                context.Clients.AddOrUpdate(c => c.ClientId, client.ToEntity());
            }
            context.SaveChanges();
        }
    }
figuerres commented 8 years ago

also at least as of 5.0 there is an interface that has been dropped that throws a runtime error "The type initializer for 'IdentityServer3.EntityFramework.Entities.EntitiesMap' threw an exception.", "System.TypeInitializationException", Could not load type 'AutoMapper.IMapperConfiguration' from assembly 'AutoMapper, Version=5.0.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005'.

brockallen commented 8 years ago

I think the open PR addresses this. I'll get to it ASAP

brockallen commented 8 years ago

fixed on dev