我試圖在我的ASP Core RC2站點中使用openiddict和EF 7。當我嘗試創建使用dotnet ef migrations add <name>
我收到以下錯誤遷移:ASP Core違反了字符串類型參數'TRole'的約束條件
System.ArgumentException: GenericArguments[1], 'System.String', on 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`3[TUser,TRole,TContext]' violates the constraint of type 'TRole'. ---> System.TypeLoadException: GenericArguments[1], 'System.String', on 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`4[TUser,TRole,TContext,TKey]' violates the constraint of type parameter 'TRole'.
at System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.Instantiate(Type[] inst)
在我Startup.cs我有以下幾點:
services.AddIdentity<MyUser, string>()
.AddEntityFrameworkStores<MyContext>()
.AddDefaultTokenProviders()
.AddOpenIddict();
我的用戶和上下文的定義如下:
public class MyUser : IdentityUser
{
}
public class MyContext : OpenIddictContext<MyUser>
{
}
我認爲這個錯誤與我說對TRole使用字符串string
的事實有關。這是不允許的? TRole支持哪些類型?