为了账号安全,请及时绑定邮箱和手机立即绑定

System.InvalidOperationException:方案已存在:

System.InvalidOperationException:方案已存在:

C#
PIPIONE 2023-07-23 17:13:38
我有一个现有的ApplicationUser,我想修改登录的UI页面。所以这就是我决定进行脚手架手术的原因。应用程序用户.cspublic class ApplicationUser : IdentityUser {     public List<Student> Students { get; set; } }但是当我使用最后一个CLI命令时:dotnet aspnet-codegenerator identity --files="Account.Login;"我无法运行我的网络应用程序,这是它在网络上显示的内容:然后,这是日志中出现的错误:未处理的异常:System.InvalidOperationException:方案已存在:Identity.Application位于Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(字符串名称,Action 1 configureBuilder)    at  Microsoft.AspNetCore.Authentication.AuthenticationBuilder.<>c__DisplayClass4_02.b__0(AuthenticationOptions o)位于Microsoft.Extensions.Options.ConfigureNamedOptions 1.Configure(String  name, TOptions options)    at  Microsoft.Extensions.Options.OptionsFactory1.Create(字符串名称)位于Microsoft.Extensions.Options.OptionsManager 1.<>c__DisplayClass5_0.<Get>b__0()  at System.Lazy1.ViaFactory(LazyThreadSafetyMode模式)位于System.Lazy 1.ExecutionAndPublication(LazyHelper  executionAndPublication, Boolean useDefaultConstructor)    at  System.Lazy1.CreateValue( ) 在 Microsoft.Extensions.Options.OptionsCache 1.GetOrAdd(String name,  Func1 createOptions) 在 Microsoft.Extensions.Options.OptionsManager 1.Get(String name)    at  Microsoft.Extensions.Options.OptionsManager1.get_Value() 在 Microsoft.AspNetCore.Authentication.AuthenticationSchemeProvider..ctor(IOptions1  options, IDictionary2 个方案)位于 Microsoft.AspNetCore.Authentication.AuthenticationSchemeProvider..ctor(IOptions1  options)
查看完整描述

1 回答

?
LEATH

TA贡献1936条经验 获得超6个赞

检查IdentityHostingStartup.cs并注释掉下面的行(如果存在):

services.AddDefaultIdentity<IdentityUser>()
    .AddEntityFrameworkStores<ICFERAppIdentityDbContext>();

简而言之,只需要一种身份配置。 


查看完整回答
反对 回复 2023-07-23
  • 1 回答
  • 0 关注
  • 147 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信