小编Lap*_*mir的帖子

EntityFramework核心自动迁移

是否有任何代码Entity Framework core code first在asp.net核心项目中执行自动迁移?

我只是在MVC4/5中添加

Database.SetInitializer(new MigrateDatabaseToLatestVersion<AppDbContext, MyProject.Migrations.Configuration>());
public Configuration() {
          AutomaticMigrationsEnabled = true;
        }
Run Code Online (Sandbox Code Playgroud)

这节省了实体更改的时间

entity-framework entity-framework-core asp.net-core

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

asp核心ef在生产服务器上的迁移

无法在生产服务器上执行迁移.命令"dotnet ef数据库更新"在我的计算机上运行但生产失败我尝试的步骤是:1 execute code first migrations.在发布之前填写Visual Studio 中的复选框.2. dotnet ef database update不工作 我安装了.NET SDK,但它没有所需的库.

任何建议都是指定的.

entity-framework entity-framework-core asp.net-core

5
推荐指数
2
解决办法
2402
查看次数

在 Vue 的递归组件中传递作用域槽

我想实现 vue 组件 - 树。每个节点不知道如何显示自己,客户应该知道(见第 5 行)。我想为父节点和所有子节点设置作用域插槽。但是子数据没有传递到第 3 级正确显示。示例https://codepen.io/vlapenkov/pen/gOpbxRG?editors=1011

<div id="app" class="jstree jstree-default jstree-default-medium">
  <ul class="jstree-container-ul jstree-children jstree-no-icons">
    <tree-item
      v-for="(child, index) in treeData"
      :item="child"
      :is-last="treeData.length-1 === index"
      :level="0"
    >
      <template scope="shape">
        <div style="position:relative; display:inline-block;">{{ shape.name }}</div>
      </template>
    </tree-item>
  </ul>
</div>

<template id="item-template" >
  <li class="jstree-node" v-bind:class="className">
    <i class="jstree-icon jstree-ocl" v-on:click="toggle"></i>
    <a class="jstree-anchor" href="#" v-bind:class=" isSelected ? 'jstree-clicked':''">
      <i class="jstree-icon jstree-themeicon"></i>
      <span>{{item.name}}</span>
      <slot v-bind="item"></slot>
    </a>
    <ul v-show="isOpen" class="jstree-children">
      <tree-item
        v-for="(child, index) in item.children"
        :key="index"
        :item="child"
        :is-last="item.children.length-1 === index"
        :level="level+1"
      > …
Run Code Online (Sandbox Code Playgroud)

vue.js

5
推荐指数
1
解决办法
394
查看次数

asp.net 核心的分页列表

在 MVC 5 (.Net Framework 4.6) 中,我使用 PagedList.Mvc 和以下解决方案:

  1. 它将查询分成页面并获取所需页面的结果(并非所有查询结果)。
  2. 它使用 HtmlHelper 来渲染具有所需过滤器的按钮组!
    1. 我可以自定义要显示的寻呼机按钮的数量(如果得到大的结果集)。

在 asp.net core 2.0 文档https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/sort-filter-page我找不到 2 和 3 解决方案。有谁知道更好的方法?

pagedlist asp.net-core

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

角钢5的旋转变压器有什么好处

我是Angular 2+中的新手。有些人在获取数据的HTTP服务和组件之间使用Resolver

export class UserResolver implements Resolve<User> {

constructor(
    private service: UserService,
    private router: Router
) {}

resolve(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
): Observable<User> {
    const id = route.paramMap.get('id');
    return this.service.getUser(+id)
        .catch(err => {
            console.error(err); // deal with API error (eg not found)
            this.router.navigate(['/']); // could redirect to error page
            return Observable.empty<User>();
        });
}
Run Code Online (Sandbox Code Playgroud)

}

问题是:

  1. 这样做的实际好处是什么?(我仅将冗余类视为每次调用的桥梁)
    1. 这是推荐的方法,是否应该重构现有代码。

angular

4
推荐指数
2
解决办法
2325
查看次数

网络调用 /.well-known/openid-configuration/ 和 /.well-known/openid-configuration/jwks

我有 :

  • 身份服务器4,
  • 具有 OpenId Connect 和混合流的 Mvc 应用程序
  • WebApi应用程序

假设用户已经获得带有 id_token 和访问令牌的 cookie。然后他从 mvc 应用程序调用一个操作:

 var client = new HttpClient();
 client.SetBearerToken(accessToken);
// call webapi from mvc
 var content = await client.GetStringAsync("http://localhost:5001/api/resource-with-policy");
Run Code Online (Sandbox Code Playgroud)

在 fiddler 中我看到两个调用:

  • GET /.well-known/openid-configuration/

  • GET /.well-known/openid-configuration/jwks

我假设 WebApi 在操作上看到 [Authorize] 属性并进行这些调用。这些电话的目的是什么?

WebApi 的配置方式如下:

              .AddJwtBearer("Bearer", options =>
              {options.Authority = "<is4-url>";
                  options.RequireHttpsMetadata = false;
                  options.Audience = "Api1";
              });```

Run Code Online (Sandbox Code Playgroud)

asp.net-core identityserver4

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

主线程是否等待子线程完成?

我有 Windows 上的 .net core 和简单的代码。如您所见,没有Join()礼物。所以主线程不等待子线程,但是当我运行时:

C:\...\bin\Release\netcoreapp3.1>dotnet ConsoleAppTest.dll
> 4
> mission complete
> Thread complete
Run Code Online (Sandbox Code Playgroud)

C#代码:

C:\...\bin\Release\netcoreapp3.1>dotnet ConsoleAppTest.dll
> 4
> mission complete
> Thread complete
Run Code Online (Sandbox Code Playgroud)

我认为主线程应该运行而不是等待子线程。我错了吗?

当我启动时

 Task.Run(() =>
            {
                Thread.Sleep(10000);
                Console.WriteLine("Thread complete");
            });
Run Code Online (Sandbox Code Playgroud)

主线程不等待

.net c# multithreading .net-core

0
推荐指数
1
解决办法
694
查看次数