I'm new to UWP and I'm trying to set up my project to use SQLite database, I'm making use of the Microsoft.EntityFrameworkCore.SQLite.
When I try to set up the database context, I keep getting this error.
DbContextOptionsBuilder does not contain definition for UseSqlite and no accessible extension method accepting a first argument of type DBcontextoptionsbuilder could be found (are you using directive or assembly reference)
Here's my code
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BradamaInternationalSkill.Models
{
/// <summary>
/// The Entity Framework Database Context.
/// </summary>
public class PersonContext : DbContext
{
internal DbSet<Person> People { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Filename=People.db");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Make Id required.
modelBuilder.Entity<Person>()
.Property(p => p.Id)
.IsRequired();
// Make Name required.
modelBuilder.Entity<Person>()
.Property(p => p.Name)
.IsRequired();
}
}
}
I solved the issue by uninstalling the Nuget package "Microsoft Entity Framework Core" and installing "Entity.Framework.Core.Sqlite.Design". I don't know why it solved the issue but the error is gone, I'm happy and that's all that matters.
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