Asp.net core mvc 算术运算导致溢出(更新asp核心数据库)

Asp.net core mvc 算术运算导致溢出(更新asp核心数据库),asp.net-core-mvc,asp.net-core-webapi,Asp.net Core Mvc,Asp.net Core Webapi,我刚转到asp核心。我想在asp核心中使用ef创建一个数据库。我添加了一个名为Person的smple类,并在DbContext中使用它,然后在项目根目录的命令行中添加了dotnet ef,之后向项目添加了迁移,但当我尝试在命令行中更新数据库时,我遇到了以下错误: 算术运算导致溢出 这是我的密码: 这是我的项目json: { "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": tr

我刚转到asp核心。我想在asp核心中使用ef创建一个数据库。我添加了一个名为Person的smple类,并在DbContext中使用它,然后在项目根目录的命令行中添加了
dotnet ef
,之后向项目添加了迁移,但当我尝试在命令行中更新数据库时,我遇到了以下错误:

算术运算导致溢出

这是我的密码: 这是我的项目json:

   {
   "buildOptions": {
   "emitEntryPoint": true,
   "preserveCompilationContext": true
   },
   "dependencies": {
   "EntityFramework.Core": "7.0.0-rc1-final",
   "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
   "Microsoft.AspNetCore.Mvc": "1.0.0",
   "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
   "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
   "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
   "Microsoft.EntityFrameworkCore.SqlServer.Design": {
     "version": "1.0.0",
     "type": "build"
   },
   "Microsoft.EntityFrameworkCore.Tools": {
     "version": "1.0.0-preview2-final",
     "type": "build"
   },
  "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
  "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
  "Microsoft.Extensions.Configuration.Json": "1.0.0",
  "Microsoft.Extensions.Logging": "1.0.0",
  "Microsoft.Extensions.Logging.Console": "1.0.0",
  "Microsoft.Extensions.Logging.Debug": "1.0.0",
  "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
  "Microsoft.NETCore.App": {
    "version": "1.0.0",
    "type": "platform"
  }
},
"Microsoft.EntityFrameworkCore.Tools": {
    "version": "1.0.0-preview2-final",
    "imports": [
      "portable-net45+win8"
    ]
},
"frameworks": {
    "netcoreapp1.0": {
    "imports": [
      "dotnet5.6",
      "portable-net45+win8"

    ]
  }
},
"publishOptions": {
  "include": [
    "wwwroot",
    "Views",
    "Areas/**/Views",
    "appsettings.json",
    "web.config"
  ]
},
"runtimeOptions": {
    "configProperties": {
    "System.GC.Server": true
  }
},
"scripts": {
  "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath%     --framework %publish:FullTargetFramework%" ]
},
"tools": {
  "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-  final",
  "Microsoft.EntityFrameworkCore.Tools": {
    "version": "1.0.0-preview1-final",
    "imports": [
      "portable-net45+win8+dnxcore50",
      "portable-net45+win8"
    ]
  }
}
}

appsetting.json:

"ConnectionStrings": {
  "ApplicationDbContextConnection": "Data Source=(local);Initial Catalog=TestDbCore2016;Integrated Security = true"
}
}

dbcontext:

  public class ApplicationDbContext : DbContext
  {
      private readonly IConfigurationRoot _configuration;
      public ApplicationDbContext(IConfigurationRoot configuration)
      {
          _configuration = configuration;
      }

      public DbSet<Person> Persons { get; set; }
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
             optionsBuilder.UseSqlServer(_configuration["ConnectionStrings:ApplicationDbContextConnection"]);
      }
  }
公共类ApplicationDbContext:DbContext
{
专用只读IConfigurationRoot\u配置;
公共应用程序上下文(IConfigurationRoot配置)
{
_配置=配置;
}
公共DbSet Persons{get;set;}
配置时受保护的覆盖无效(DBContextOptions Builder Options Builder)
{
optionsBuilder.UseSqlServer(_配置[“ConnectionString:ApplicationDbContextConnection]”);
}
}
创业班

public class Startup
{
    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables();
        Configuration = builder.Build();
    }

    public IConfigurationRoot Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddMvc();
        services.AddSingleton<IConfigurationRoot>(provider => { return Configuration; });
        services.AddDbContext<ApplicationDbContext>(ServiceLifetime.Scoped);
        services.AddScoped<IUnitOfWork, ApplicationDbContext>();
        services.AddScoped<IPersonService, PersonService>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug();

        app.UseMvc();
        if (env.IsDevelopment())
        {
            app.UseDatabaseErrorPage();
        }
    }
}
公共类启动
{
公共启动(IHostingEnvironment环境)
{
var builder=new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile(“appsettings.json”,可选:true,重载更改:true)
.AddJsonFile($“appsettings.{env.EnvironmentName}.json”,可选:true)
.AddenEnvironmentVariables();
Configuration=builder.Build();
}
公共IConfigurationRoot配置{get;}
//此方法由运行时调用。请使用此方法将服务添加到容器中。
public void配置服务(IServiceCollection服务)
{
//添加框架服务。
services.AddMvc();
AddSingleton(provider=>{return Configuration;});
services.AddDbContext(ServiceLifetime.Scoped);
services.addScope();
services.addScope();
}
//此方法由运行时调用。请使用此方法配置HTTP请求管道。
公共void配置(IApplicationBuilder应用程序、IHostingEnvironment环境、iLogger工厂)
{
loggerFactory.AddConsole(Configuration.GetSection(“Logging”);
loggerFactory.AddDebug();
app.UseMvc();
if(env.IsDevelopment())
{
app.UseDatabaseErrorPage();
}
}
}

嘿,我也面临这个问题。有人找到解决办法了吗?