添加迁移问题

时间:2017-05-08 20:17:58

标签: c# asp.net visual-studio asp.net-core entity-framework-core

我的ASP.NET核心应用程序出了问题。我想使用Entity Framework添加数据库,但Visual Studio 2015显示以下错误。

请您查看我的文件并让我知道我的申请有什么问题?非常感谢你提前。

  

启动项目&#s; src \ Store'是一个ASP.NET核心或.NET核心项目   对于Visual Studio 2015.此版本的实体框架核心   软件包管理器控制台工具不支持这些类型的项目。

project.json

{

      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.1",
          "type": "platform"
        },
        "Microsoft.AspNetCore.Diagnostics": "1.0.0",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
        "Microsoft.Extensions.Logging.Console": "1.0.0",
        "Microsoft.AspNetCore.Razor.Tools": {
          "version": "1.0.0-preview2-final",
          "type": "build"
        },
        "Microsoft.AspNetCore.StaticFiles": "1.0.0",
        "Microsoft.AspNetCore.Mvc": "1.0.1",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
        "Microsoft.EntityFrameworkCore.Tools": "1.1.0",
        "Microsoft.Extensions.Configuration.Json": "1.0.0"
      },

      "tools": {
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
        "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
        "Microsoft.EntityFrameworkCore.Tools": {
          "version": "1.0.0-prview2-final",
          "imports": [ "portable-net45+win8+dnxcore50", "portable-net45+win8" ]
        }
      },

      "frameworks": {
        "netcoreapp1.0": {
          "imports": [
            "dotnet5.6",
            "portable-net45+win8"
          ]
        }
      },

      "buildOptions": {
        "emitEntryPoint": true,
        "preserveCompilationContext": true
      },

      "runtimeOptions": {
        "configProperties": {
          "System.GC.Server": true
        }
      },

      "publishOptions": {
        "include": [
          "wwwroot",
          "web.config"
        ]
      },

      "scripts": {
        "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
      }
    }

appsettings.json

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=Store;Trusted_Connection=True;MultipleActiveResultSets=true"
  }
}

Startup.cs

public class Startup
    {
        private IConfigurationRoot _configurationRoot;  

        public Startup(IHostingEnvironment hostingEnvironment)
        {
            _configurationRoot = new ConfigurationBuilder()
                .SetBasePath(hostingEnvironment.ContentRootPath)
                .AddJsonFile("appsetting.json")
                .Build();
        }

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<AppDbContext>(options =>
                                        options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection")));
            services.AddTransient<ICategoryRepository, CategoryRepository>();
            services.AddTransient<IAlbumRepository, AlbumRepository>();
            services.AddMvc();
        }

        // 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)
        {
            app.UseDeveloperExceptionPage();
            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
    }

0 个答案:

没有答案