dbcontext支架.Net Core 2.1生成算术过低

时间:2018-08-17 15:15:51

标签: entity-framework .net-core

表格: 创建表[dbo]。[test1]([test1] [int]不为空,  约束[PK_test1]主键([test1] ASC)

命令: dotnet ef dbcontext支架“ Server = tcp:db-sql-370,33416 \;初始目录= GISPROCESS; Trusted_Connection = True;” Microsoft.EntityFrameworkC ore.SqlServer -o模型-t test1 --schema dbo

错误: 将表达式转换为数据类型bigint的算术溢出错误。

我可以发布完整的堆栈跟踪信息,但是我想从此开始。

1 个答案:

答案 0 :(得分:0)

无法复制。从一个空目录运行它:

rm * 

$sql = @"
drop table if exists test1;
CREATE TABLE [dbo].[test1]
( 
  [test1] [int] NOT NULL, 
  CONSTRAINT [PK_test1] PRIMARY KEY CLUSTERED ([test1] ASC) 
)
"@

Invoke-Sqlcmd -server . -database tempdb -Query $sql

dotnet new console -n test

$proj = @"
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
  </ItemGroup>

</Project>
"@

$proj | out-file -FilePath test.csproj 

dotnet restore

dotnet ef dbcontext scaffold "Server=.;Initial Catalog=tempdb;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models -t test1 --schema dbo

type Models\test1.cs