这里的问题是如何生成由两个外键组成的复合主键?
我试过了:
public class ActiveQuestions_Questions
{
[Column(Order = 0), Key, ForeignKey("ActiveQuestion")]
public string ActiveQuestionId {get; set;}
[Column(Order = 1), Key, ForeignKey("Question")]
public string QuestionId {get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这给了我:实体类型'ActiveQuestions_Questions'具有使用数据注释定义的复合主键.要设置复合主键,请使用fluent API.
然后我尝试在没有注释的模型构建器中使用流畅的api.
builder.Entity<ActiveQuestions_Questions>(
build =>
{
build.HasKey(t => new {t.ActiveQuestionId, t.QuestionId});
build.HasOne(t => t.QuestionId).WithOne().HasForeignKey<Question>(qe => qe.QuestionId);
build.HasOne(t => t.ActiveQuestionId).WithOne().HasForeignKey<ActiveQuestion>(qe => qe.ActivateQuestionId);
}
);
Run Code Online (Sandbox Code Playgroud)
这给了我:导航属性'QuestionId'无法添加到实体类型'ActiveQuestions_Questions',因为实体类型'ActiveQuestions_Questions'上已经存在具有相同名称的属性.
谁能指出我正确的方向?
问题类
public class Question
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string QuestionId {get; set;}
[Required]
public string Text {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
ActiveQuestion类:
public class ActiveQuestion
{
private DateTime …Run Code Online (Sandbox Code Playgroud) 因此,我尝试使用实现OpenIddict版本1.0.0-beta2-0580,NET core 1.1并且出现以下错误:
An unhandled exception occurred while processing the request
这是基于以下内容的:https : //github.com/openiddict/openiddict-core/tree/dev/samples

db正确注册了数据库,设置已加载,并且一切正常。在数据库中的表:__efmigrationshistory,aspnetroleclaims,aspnetroles,aspnetuserclaims,aspnetuserlogins,aspnetuserroles,aspnetusers,aspnetusertokens,basetransaction,openiddictapplications,openiddictauthorizations,openiddictscopes,openiddicttokens
然后我有以下堆栈跟踪:
InvalidOperationException: The authentication ticket was rejected because the mandatory subject claim was missing.
AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerHandler+<HandleSignInAsync>d__5.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Authentication.AuthenticationHandler+<SignInAsync>d__66.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Http.Authentication.Internal.DefaultAuthenticationManager+<SignInAsync>d__14.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.SignInResult+<ExecuteResultAsync>d__14.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeResultAsync>d__30.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeNextResultFilterAsync>d__28.MoveNext() …Run Code Online (Sandbox Code Playgroud) 所以我试图从 url 获取值,我想用 promise 和 async/await 来做到这一点。但是当我在 Chrome 和歌剧中运行它时,它只是站在那里等待这一点。任何人都可以指出我正确的方向还是我做错了什么?
我的组件实现:实现 OnInit
构造函数:
constructor(private route: ActivatedRoute,
private zone : NgZone
)
{
}
Run Code Online (Sandbox Code Playgroud)
进口:
import { Component, OnInit, NgZone } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Rx';
Run Code Online (Sandbox Code Playgroud)
方法:
async ngOnInit()
{
var Id : string = await this.getIdFromUrl();
}
getIdFromUrl() : Promise<string>
{
return this.route.params.map(params =>
{
return params['id'];
}).toPromise();
}
Run Code Online (Sandbox Code Playgroud)