小编Sto*_*orm的帖子

EF Core 数据库中已经有一个名为“AspNetRoles”的对象

我正在接收数据库中已经有一个命名的对象AspNetRoles尝试update-database在 NuGet 控制台中使用命令时出错。

语境:

public class ApplicationDbContext : IdentityDbContext<IdentityUser>
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }


    public DbSet<Customer> Customers { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

启动:

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
                b => b.MigrationsAssembly("DroneDeliveryWebApi")));

            // …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework asp.net-identity entity-framework-core asp.net-core

6
推荐指数
1
解决办法
6370
查看次数

拖放到 Angular 材质嵌套树上

我正在尝试在 Angular 材质嵌套树上实现拖放。树本身和拖放逻辑运行良好。
问题是我无法定位正确的节点以将拖动的元素放入其中
例如我有这样的结构:

在此输入图像描述

如果我尝试更改元素的位置,例如 Child1 从 Group2 并将其移动到 Group1,它将无法正常工作
在此输入图像描述
=>

在此输入图像描述

如您所见,Child1 现在与 Group1 和 Group2 处于同一级别。我想再次提及 drop() 函数工作正常,因为它返回正确的索引。它只是根据它收到的索引更改数组中的元素位置,这意味着它从开头得到错误的索引 在此输入图像描述

所以问题应该出在标记或CSS中。
我花了很多时间试图理解这个问题。希望你能帮助我。

这是我的材料树的简化代码:

        <mat-tree [dataSource]="DataSource" [treeControl]="TreeControl" cdkDropList
            (cdkDropListDropped)="drop($event)">
            <mat-nested-tree-node *matTreeNodeDef="let node; when: hasNestedChild" cdkDrag [cdkDragData]="node">
                <li>
                    <div>
                        <div fxLayout="row" fxLayoutAlign="start center"
                            [class.bg-primary]="selected && node.id === selected.id">
                            <button mat-icon-button matTreeNodeToggle [disabled]="node.isEmpty">
                                <mat-icon insert="true">
                                    {{TreeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
                                </mat-icon>
                            </button>
                        </div>
                    </div>
                    <ul [class.primary]="selected && node.id === selected.id"
                        [class.tree-invisible]="!TreeControl.isExpanded(node) ">
                        <ng-container matTreeNodeOutlet></ng-container>
                    </ul>
                </li>
            </mat-nested-tree-node>
            <mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle cdkDrag [cdkDragData]="node"> …
Run Code Online (Sandbox Code Playgroud)

drag-and-drop angular-material angular-material2 angular

5
推荐指数
0
解决办法
2994
查看次数

Angular,从发布请求中获取状态代码值

我想从发布请求中获取 StatusCode 值,以便在我的组件中使用它。这就是我所做的:
Api 调用:

  Login(user: User) {
    return this.http.post(apiUrl + 'account/Login', user).subscribe();
  }
Run Code Online (Sandbox Code Playgroud)

组件中的方法:

  Login() {
    this.user.UserName = this.loginForm.controls.userName.value;
    this.user.Password = this.loginForm.controls.password.value;

    this.api.Login(this.user)
  }
Run Code Online (Sandbox Code Playgroud)

现在仅显示为错误 在此输入图像描述 结果应该是这样的: 在此输入图像描述

更新
这不是cors问题...
成功登录: 在此输入图像描述

http-status-code-401 angular angular7

3
推荐指数
1
解决办法
1万
查看次数