我使用VS Code开发.Net Core RTM web api。我正在运行命令dotnet ef migrations add "myfirstMigraion"
进行迁移,然后获取错误,如下图所示。 : -
我的project.json文件如下所示: -
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.EntityFrameworkCore.Design": {
"type": "build",
"version": "1.0.0-preview2-final"
},
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions":"1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "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.EntityFrameworkCore": "1.0.0-*",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.InMemory": "1.0.0-rc2-final",
// "Microsoft.EntityFrameworkCore.Tools":"1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"debugType": "portable"
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
},
"tooling": {
"defaultNamespace": "firstCoreApi"
}
}
看起来像我的Startup.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using firstCoreApi.Model;
namespace firstCoreApi
{
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)
{
var connection = @"Server=myPcName\SQLEXPRESS; Database=StudentsDB;user id=MysqlUserId;password=Mysqlpassword;Trusted_Connection=True;MultipleActiveResultSets=true";
//Server=SQLSERVERNAME;Database=StudentsDB;user id=sa;password=sa1;Trusted_Connection=True;MultipleActiveResultSets=true;
// Add framework services.
services.AddMvc();
// services.AddDbContext<TodoListDbContext>(options => options.UseInMemoryDatabase());
services.AddDbContext<BloggingContext>(options => options.UseSqlServer(connection));
}
// 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();
}
}
}
我正在使用操作系统Windows 10和sql server 2014.我需要你的帮助人员如何解决它。
答案 0 :(得分:0)
我也出现了同样的异常,我只是“Microsoft.AspNetCore.Routing”:“1.0.0-rc2-final”改为“Microsoft.AspNetCore.Routing”:“1.0.0”.it的工作
我认为如果使用VSCODE,可以在project.json
中尝试更改"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.InMemory": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0"
答案 1 :(得分:0)
我遇到了同样的问题。从命令行安装包。帮助网站:https://www.nuget.org/packages/Kendo.Mvc/2016.2.630-Preview
在包管理器中使用的命令:Install-Package Kendo.Mvc -Pre
NuGet从搜索中返回的包是最新的稳定包,其中包含错误,哈哈!这就是您需要从包管理器中的命令行安装的原因。
Telerik了解这个问题:https://github.com/telerik/kendo-ui-core/issues/1856