当前位置: 首页 > 编程语言 > C#

OwinOAuthProvider-TheentitytypeIdentityUserisnotpartofthecurrentcontextmodel-share

时间:2023-04-10 15:59:41 C#

OwinOAuthprovider"TheentitytypeIdentityUserisnotpartofthecurrentcontextmodel"UserManagerFactory=()=>newUserManager(新用户存储());OAuthOptions=newOAuthAuthorizationServerOptions{TokenEndpointPath=newPathString("/Token"),Provider=newApplicationOAuthProvider(PublicClientId,UserManagerFactory),AuthorizeEndpointPath=newPathString("/api/AccountOwin/ExternalLogin"Exp),AccessToken14),AllowInsecureHttp=true};IdentityUser,UserStore来自哪个实体框架。我想使用我的数据库而不是本地数据库,我从本地数据库表生成“生成”脚本,我在自定义数据库中创建它们,但是当我在以下行中显示数据库上下文时:UserManagerFactory=()=>newUserManager(新的UserStore(新的MyCustomDBEntities()));其中MyCustomDBEntities是我在实体框架(edmx)中的自定义数据库我收到以下错误:“实体类型IdentityUser不是当前上下文模型的一部分”我做错了什么?我应该创建自己的用户管理器吗?publicclassMyCustomDBEntities:IdentityDbContext{publicMyCustomDBEntities():base("name=ConnectionStringName"){}}我怀疑问题出在您的连接字符串上。首先,上下文的构造函数只需要有连接字符串的名称,因此您可以将其更改为:publicMyCustomDBEntities():base("ConnectionStringName"){}其次,您可能只是在发布名称之前编辑代码需要匹配配置文件中的名称:最后,您可能需要更改连接字符串以使用标准SQLServer格式而不是EF格式。所以大概是这样的:以上就是C#学习教程:OwinOAuthProvider"EntityTypeIdentityUserisnotpartofthecurrentcontextmodel"分享的全部内容,如果对你有用,需要进一步了解C#学习教程,希望大家多多关注——DataSource=LNODA-PC;InitialCatalog=Dashboard;PersistSecurityInfo=True;UserId=XXXX;Password=XXXXXX;MultipleActiveResultSets=True;联系右侧管理员删除。如需转载请注明出处: