diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs
index 23933d9d57..a46fab5320 100644
--- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs
+++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs
@@ -96,15 +96,16 @@ namespace Microsoft.Extensions.DependencyInjection
private static TypeInfo FindGenericBaseType(Type currentType, Type genericBaseType)
{
- var type = currentType.GetTypeInfo();
- while (type.BaseType != null)
+ var type = currentType;
+ while (type != null)
{
- type = type.BaseType.GetTypeInfo();
+ var typeInfo = type.GetTypeInfo();
var genericType = type.IsGenericType ? type.GetGenericTypeDefinition() : null;
if (genericType != null && genericType == genericBaseType)
{
- return type;
+ return typeInfo;
}
+ type = type.BaseType;
}
return null;
}
diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Properties/Resources.Designer.cs
index 6e9c08a032..7db34e9f37 100644
--- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Properties/Resources.Designer.cs
+++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Properties/Resources.Designer.cs
@@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
= new ResourceManager("Microsoft.AspNetCore.Identity.EntityFrameworkCore.Resources", typeof(Resources).GetTypeInfo().Assembly);
///
- /// AddEntityFrameworkStores can only be called with a role that derives from IdentityRole<TKey, TUserRole, TRoleClaim>.
+ /// AddEntityFrameworkStores can only be called with a role that derives from IdentityRole<TKey>.
///
internal static string NotIdentityRole
{
@@ -19,13 +19,13 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
}
///
- /// AddEntityFrameworkStores can only be called with a role that derives from IdentityRole<TKey, TUserRole, TRoleClaim>.
+ /// AddEntityFrameworkStores can only be called with a role that derives from IdentityRole<TKey>.
///
internal static string FormatNotIdentityRole()
=> GetString("NotIdentityRole");
///
- /// AddEntityFrameworkStores can only be called with a user that derives from IdentityUser<TKey, TUserClaim, TUserRole, TUserLogin, TUserToken>.
+ /// AddEntityFrameworkStores can only be called with a user that derives from IdentityUser<TKey>.
///
internal static string NotIdentityUser
{
@@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
}
///
- /// AddEntityFrameworkStores can only be called with a user that derives from IdentityUser<TKey, TUserClaim, TUserRole, TUserLogin, TUserToken>.
+ /// AddEntityFrameworkStores can only be called with a user that derives from IdentityUser<TKey>.
///
internal static string FormatNotIdentityUser()
=> GetString("NotIdentityUser");
diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Resources.resx b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Resources.resx
index eb19639109..9bde296e06 100644
--- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Resources.resx
+++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/Resources.resx
@@ -118,11 +118,11 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- AddEntityFrameworkStores can only be called with a role that derives from IdentityRole<TKey, TUserRole, TRoleClaim>.
+ AddEntityFrameworkStores can only be called with a role that derives from IdentityRole<TKey>.
error when the role does not derive from IdentityRole
- AddEntityFrameworkStores can only be called with a user that derives from IdentityUser<TKey, TUserClaim, TUserRole, TUserLogin, TUserToken>.
+ AddEntityFrameworkStores can only be called with a user that derives from IdentityUser<TKey>.
error when the user does not derive from IdentityUser
diff --git a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/DefaultPocoTest.cs b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/DefaultPocoTest.cs
index 4a3d13feed..e845e0395a 100644
--- a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/DefaultPocoTest.cs
+++ b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/DefaultPocoTest.cs
@@ -1,9 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
-using System.Linq;
-using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Identity.Test;
diff --git a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/SqlStoreTestBase.cs b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/SqlStoreTestBase.cs
index 9a5b3edabc..515f62a608 100644
--- a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/SqlStoreTestBase.cs
+++ b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/SqlStoreTestBase.cs
@@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
protected override void SetupIdentityServices(IServiceCollection services, object context)
{
services.AddSingleton();
- services.AddSingleton((TestDbContext)context);
+ services.AddSingleton((TestDbContext)context);
services.AddLogging();
services.AddSingleton>>(new TestLogger>());
services.AddSingleton>>(new TestLogger>());
diff --git a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreGuidKeyTest.cs b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreGuidKeyTest.cs
index 9887736d89..de8785fdc0 100644
--- a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreGuidKeyTest.cs
+++ b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreGuidKeyTest.cs
@@ -59,5 +59,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
// This used to throw
var builder = services.AddIdentity().AddEntityFrameworkStores();
}
+
+ [Fact]
+ public void AddEntityFrameworkStoresCanInferKeyWithGenericBase()
+ {
+ var services = new ServiceCollection();
+ // This used to throw
+ var builder = services.AddIdentity, IdentityRole>().AddEntityFrameworkStores();
+ }
+
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreIntKeyTest.cs b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreIntKeyTest.cs
index 265a467b93..6a32ef04a5 100644
--- a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreIntKeyTest.cs
+++ b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreIntKeyTest.cs
@@ -37,5 +37,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
// This used to throw
var builder = services.AddIdentity().AddEntityFrameworkStores();
}
+
+ [Fact]
+ public void AddEntityFrameworkStoresCanInferKeyWithGenericBase()
+ {
+ var services = new ServiceCollection();
+ // This used to throw
+ var builder = services.AddIdentity, IdentityRole>().AddEntityFrameworkStores();
+ }
+
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreStringKeyTest.cs b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreStringKeyTest.cs
index d5ec26951d..499211381b 100644
--- a/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreStringKeyTest.cs
+++ b/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreStringKeyTest.cs
@@ -39,5 +39,13 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
var builder = services.AddIdentity().AddEntityFrameworkStores();
}
+ [Fact]
+ public void AddEntityFrameworkStoresCanInferKeyWithGenericBase()
+ {
+ var services = new ServiceCollection();
+ // This used to throw
+ var builder = services.AddIdentity, IdentityRole>().AddEntityFrameworkStores();
+ }
+
}
}
\ No newline at end of file