nic*_*ick 5 sqlite entity-framework-core asp.net-core-2.1
我正在ASP.NET Core 2.1中启动一个Razor页面项目.我正在尝试使用SQLite,但在配置数据库时,只有SQL Server似乎是一个选项.
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
Intellisense无法识别options.UseSqlite和构建失败.对于.net核心2.0项目,这不是/不是问题.
这不支持吗?阅读文档使它看起来像是.我不确定这里还有什么问题.
| 归档时间: |
|
| 查看次数: |
9152 次 |
| 最近记录: |