在ASP中使用MVC6的依赖冲突.网络应用程序

本文关键字:依赖 冲突 网络 应用程序 MVC6 ASP | 更新日期: 2023-09-27 18:13:33

这可能是依赖冲突吗?我得到了错误。我已经尝试改变依赖关系,但它仍然返回这些错误,请我需要你的支持。这就是项目。json文件

"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "EntityFramework.SqlServer": "7.0.0-beta5",
    "EntityFramework.Commands": "7.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta8"
  },

StartUp.cs文件:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
using MyQuotesApps.models;
using Microsoft.Framework.Runtime;
using Microsoft.Framework.Configuration;
using Microsoft.AspNet.Hosting;
namespace MyQuotesApps
{
    public class Startup
    {
        public IConfiguration Configuration { get; set; }
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddEntityFramework().AddSqlServer()
                .AddDbContext<QuotesAppContext>(options =>options.UseSqlServer(Configuration["Data:ConnectionString"]));
        }
        public Startup(IHostingEnvironment env, IApplicationEnvironment appenv) {
            var configurationBuilder = new ConfigurationBuilder(appenv.ApplicationBasePath);
            configurationBuilder.AddJsonFile("config.json");
            configurationBuilder.AddEnvironmentVariables();
            Configuration = configurationBuilder.Build();
        }
        public void Configure(IApplicationBuilder app)
        {
            app.UseMvc();
        }
    }
}

返回以下错误:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1503  Argument 1: cannot convert from 'string' to 'Microsoft.Framework.Configuration.IConfigurationProvider'  MyQuotesApps.DNX 4.5.1, MyQuotesApps.DNX Core 5.0   C:'Users'ken4ward'documents'visual studio 2015'Projects'MyQuotesApps'src'MyQuotesApps'Startup.cs    28  Active
Error   CS1061  'EntityOptionsBuilder' does not contain a definition for 'UseSqlServer' and no extension method 'UseSqlServer' accepting a first argument of type 'EntityOptionsBuilder' could be found (are you missing a using directive or an assembly reference?)   MyQuotesApps.DNX 4.5.1, MyQuotesApps.DNX Core 5.0   C:'Users'ken4ward'documents'visual studio 2015'Projects'MyQuotesApps'src'MyQuotesApps'Startup.cs    24  Active

在ASP中使用MVC6的依赖冲突.网络应用程序

你必须迁移到ASP.net Core 1.0。如果你还在使用测试版,你就有大麻烦了。所以开始迁移或者用最新的包创建一个新项目。

或者从最新的。net核心开始:。Net Core 1.0

开始使用ASP。. NET Core MVC和Visual Studio