小编Itc*_*don的帖子

升级到ASP.NET Core 2.0后无法创建迁移

升级到ASP.NET Core 2.0后,我似乎无法再创建迁移.

我越来越

"在类'Program'上调用方法'BuildWebHost'时发生错误.继续没有应用服务提供者.错误:发生了一个或多个错误.(无法打开登录请求的数据库"...".登录失败.登录用户'...'失败

"无法创建'MyContext'类型的对象.将'IDesignTimeDbContextFactory'的实现添加到项目中,或者参见 https://go.microsoft.com/fwlink/?linkid=851728以获取在设计时支持的其他模式."

我之前运行的命令是$ dotnet ef migrations add InitialCreate --startup-project "..\Web"(来自带有DBContext的项目/文件夹).

连接字符串: "Server=(localdb)\\mssqllocaldb;Database=database;Trusted_Connection=True;MultipleActiveResultSets=true"

这是我的Program.cs

 public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
       WebHost.CreateDefaultBuilder(args)
           .UseStartup<Startup>()
           .Build();
}
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core asp.net-core-mvc asp.net-core asp.net-core-2.0

86
推荐指数
6
解决办法
7万
查看次数

根据字符的出现对列表进行排序

我想输入一个字符串列表,并使用python函数sort()或按出现的字符对它们进行排序sorted()。我可以在编写自己的排序函数的许多代码行中做到这一点,我只是不确定如何在python中如此轻松地做到这一点

sorted()其而言可以取列表和关键

l = ['a', 'wq', 'abababaaa']
#I think it's something like this, I know I'm missing something
sorted(l, key = count('a'))

Run Code Online (Sandbox Code Playgroud)

预期的结果将是

['wq', 'a', 'abababaaa']
Run Code Online (Sandbox Code Playgroud)

python python-3.x

6
推荐指数
2
解决办法
72
查看次数

如何对齐颤振列小部件中的文本?

我想垂直对齐左侧元素,并与带有填充的右侧元素相同,这就是我得到的结果,元素未对齐,并且我无法在第二行中插入填充,以便左侧元素对齐

在此输入图像描述

         return InkWell(
           child: Column(

            children: <Widget>[
               Row(
                 children:<Widget> [
                 Padding(padding:EdgeInsets.fromLTRB(18.0, 0.0, 0.0, 0.0)),

                 Text(
                 product.libelle,
                 style: theme.textTheme.title,
                 maxLines: 1,
                 textAlign: TextAlign.left,
                 ),]),


             Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children:<Widget> [
              Text(
              product.description,
              style: theme.textTheme.subtitle,
              maxLines: 1,

             ),
         RaisedButton( onPressed: () {},
         child: new Text("S\'abonner"),
         )

       ]),
       ),
         );
Run Code Online (Sandbox Code Playgroud)

flutter

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

Docker 堆栈部署:无法设置 dnsrr,因为端口暴露为入口

使用 stack deploy 启动服务时,我们收到以下错误:

“来自守护进程的错误响应:rpc 错误:代码 = 3 desc = EndpointSpec:以入口模式发布的端口不能与 dnsrr 模式一起使用”

测试让我尝试:使用ignress=falseset手动创建网络,在不公开端口的情况下启动堆栈部署并将节点加入网络,然后手动公开端口。

docker service update --publish-add 5672:5672 service_name1
Run Code Online (Sandbox Code Playgroud)

但仍然得到同样的错误。

有什么想法吗?

ports docker

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

如何在内联样式属性 (React) 中延迟加载背景图像?

我目前正在开发我的第一个 React 应用程序,但我正面临一些困难(对我而言)。

<div
    className="container-fluid"
    id="cityDetail"
    style={{
        backgroundImage: `url(${camera.lastPhoto})`,
        backgroundRepeat: "no-repeat",
        backgroundPosition: "center",
        backgroundSize: "cover",
        height: "100vh"
    }}
>
Run Code Online (Sandbox Code Playgroud)

我想延迟加载 backgroundImage。

我还没有找到好的组件/实用程序来做到这一点。有没有人有任何想法?

javascript lazy-loading reactjs

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

Postgresql (pgsql) 客户端期望套接字位于与 postgrsql-server 不同的位置

当尝试连接到我的工作站上本地运行的 postgres 时,我得到:

$ sudo -u postgres psql -c "create role ..."
could not change directory to "/home/esauer/workspace/cfme"
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

我的 postgres-server 安装在/var/run/postgresql.

如何让客户看向正确的位置?

postgresql

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

在Ubuntu 16.04上安装ROS Kinetic时出错

当我尝试执行以下操作时:

sudo apt-get install ros-kinetic-desktop-full
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

E: Unable to locate package ros-kinetic-desktop-full
Run Code Online (Sandbox Code Playgroud)

然后,我尝试寻找一种解决方法,从源安装它,一旦运行rosdep install --from-paths . -i -y --rosdistro kinetic,它将引发以下错误:

executing command [sudo -H apt-get install -y ros-kinetic-gazebo-dev]
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ros-kinetic-gazebo-dev
ERROR: the following rosdeps failed to install
apt: command [sudo -H apt-get install -y ros-kinetic-gazebo-dev] failed
Run Code Online (Sandbox Code Playgroud)

任何想法出什么问题了吗?

ubuntu ros ubuntu-16.04

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

如何在 jenkinsfile 中定义和使用函数?

我想将 git diff shell 脚本的输出检索到变量中,然后在其上运行用户定义的函数。我如何声明我想要编写的这些函数以及如何使用它们?

pipeline{
agent any
parameters {
        string(name: 'branchA', defaultValue: 'master', description: 'Comapare which branch?')

        string(name: 'branchB', defaultValue: 'dev', description: 'Compare with which branch?')
}

stages {
    stage('Build') {
        steps{
            checkout([$class: 'GitSCM',
                branches: [[name: '*/master']],
                doGenerateSubmoduleConfigurations: false,
                extensions: [[$class: 'CleanBeforeCheckout']],
                submoduleCfg: [],
                userRemoteConfigs:  [[credentialsId: 'gitCreds', url: "https://github.com/DialgicMew/example.git"]]])
 
                sh "git diff --name-only remotes/origin/${params.branchA} remotes/origin/${params.branchB}"    
         }
    
    stage('Functions on the result') {
        steps{
            echo "Functions to be used here"
        }
    }
}
}
```




Run Code Online (Sandbox Code Playgroud)

jenkins jenkins-groovy jenkins-pipeline

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

为什么我在角度通用的 ngx_cookieconsent_NgcCookieConsentService.init 中无法读取未定义的属性“初始化”?

CookieConsent 和库版本?

\n
- cookieconsent version: 3.1.1\n- ngx-cookieconsent version: 2.2.3\n- Angular CLI: 10.0.3\n- Angular SSR (universal)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在运行以下命令:

\n
npm run build:ssr && npm run serve:ssr\n
Run Code Online (Sandbox Code Playgroud)\n

在哪里:

\n
"serve:ssr": "node dist/compy/server/main.js",\n\n"build:ssr": "ng build --prod && ng run compy:server:production",\n
Run Code Online (Sandbox Code Playgroud)\n

失败给出的日志

\n\n
Node Express server listening on http://localhost:4000\n\nERROR TypeError: Cannot read property 'initialise' of undefined\n    at NgcCookieConsentService.init (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:3482889)\n    at new NgcCookieConsentService (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:3482119)\n    at Object.NgcCookieConsentService_Factory [as factory] (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:3484065)\n    at R3Injector.hydrate (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:2802301)\n    at R3Injector.get (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:2799033)\n    at NgModuleRef$1.get (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:2977443)\n    at Object.get (C:\\Coding\\compyFront\\dist\\compy\\server\\main.js:1:2946537)\n    at …
Run Code Online (Sandbox Code Playgroud)

server-side-rendering angular-universal angular cookieconsent

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

Swagger UI 中的掩码输入(示例 - 密码)?

我有一个 API 的三个路径变量。我想用 ***** 屏蔽 Swagger UI 上的一个输入。

使用 Springdoc OpenAPI 时如何做到这一点?

swagger-ui openapi springdoc-openapi-ui

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