UseSqlite with Entity Framework Core in ASP.NET Core 2.1 不工作

UseSqlite with Entity Framework Core in ASP.NET Core 2.1 not working

我正在 ASP.NET Core 2.1 中启动一个 Razor 页面项目。我正在尝试使用 SQLite 但是当仅配置数据库时 SQL 服务器似乎是一个选项。

Startup.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Application.Models;
using Microsoft.EntityFrameworkCore;

namespace Application
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<ApplicationContext>(options =>
               options.UseSqlite("Data Source=Database.db"));
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseStaticFiles();
            app.UseMvc();
        }
    }
}

Intellisense 无法识别 options.UseSqlite 并且构建失败。这不是/不是 .net core 2.0 项目的问题。

这还不支持吗?通读文档似乎是这样。我不确定这里还有什么问题。

你的项目好像没有安装Microsoft.EntityFrameworkCore.Sqlite

我也有同样的问题但是在安装包之后 安装包 Microsoft.EntityFrameworkCore.Sqlite - 版本 2.1.1

从 Nuget 安装 Microsoft.EntityFrameworkCore.Sqlite 包,并确保包版本也与您的目标框架版本兼容。