I am starting a Razor pages project in ASP.NET Core 2.1. I am trying to use SQLite but when configuring the database only SQL Server seems to be an option.
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 does not recognize options.UseSqlite
and builds fail. This was not/ is not an issue with .net core 2.0 projects.
Is this not supported yet? Reading through the documentation makes it seem that it is. I'm not sure what else is going wrong here.
To use Entity Framework 6, your project has to compile against . NET Framework, as Entity Framework 6 doesn't support . NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.
EF Core does not support the EDMX file format for models.
NET Standard 2.1 platform. This means EF Core 5.0 will run on . NET Core 3.1 or . NET 5, as well as other platforms that support .
It’s seems that you have not installed Microsoft.EntityFrameworkCore.Sqlite to the project.
I also had same issue but after installing package Install-Package Microsoft.EntityFrameworkCore.Sqlite -Version 2.1.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With