DbContextBuilder does not contain definition for UseSqlite

c# entity-framework-core sqlite uwp

Question

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();
        }
    }
}
1
4
9/8/2018 9:58:47 PM

Accepted Answer

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.

4
9/11/2018 7:55:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow