我是 UWP 的新手,我正在嘗試設(shè)置我的項目以使用 SQLite 數(shù)據(jù)庫,我正在使用 Microsoft.EntityFrameworkCore.SQLite。當(dāng)我嘗試設(shè)置數(shù)據(jù)庫上下文時,我不斷收到此錯誤。DbContextOptionsBuilder 不包含 UseSqlite 的定義,并且找不到接受 DBcontextoptionsbuilder 類型的第一個參數(shù)的可訪問擴(kuò)展方法(您使用的是指令還是程序集引用)這是我的代碼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 回答

江戶川亂折騰
TA貢獻(xiàn)1851條經(jīng)驗 獲得超5個贊
我通過卸載 Nuget 包“Microsoft Entity Framework Core”并安裝“Entity.Framework.Core.Sqlite.Design”解決了這個問題。我不知道為什么它解決了這個問題,但錯誤消失了,我很高興,這才是最重要的。
- 1 回答
- 0 關(guān)注
- 541 瀏覽
添加回答
舉報
0/150
提交
取消