当前位置: 首页 > news >正文

You need to call SQLitePCL.raw.SetProvider()

在.NET环境中使用Entity Framework Core(EF Core)连接SQLite数据库时,报错。
使用框架 .NET8
错误信息:
Exception: You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().

这个错误主要原因就是没有安装nuget包: SQLitePCLRaw.bundle_e_sqlite3

需要安装包:
SQLitePCLRaw.bundle_e_sqlite3,版本 2.1.10
Microsoft.EntityFrameworkCore.Sqlite.Core,版本 9.0.0

ef core上下文参考代码:

using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System.Reflection.Metadata;
using WpfRepairProject.Model;namespace WpfRepairProject.IData_impl
{public class EFContextSQLite : DbContext{protected override void OnConfiguring(DbContextOptionsBuilder options){try{ string  filePath = "G:\\DataBase\\ljRepaireProject.sqlite"; options.UseSqlite($"Data Source={filePath}");             //设置不跟踪所有查询  options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);#if DEBUG//启用敏感数据日志记录options.EnableSensitiveDataLogging();//记录日志          options.LogTo(msg =>{//调试-窗口消息System.Diagnostics.Debug.WriteLine(msg);//输出-窗口消息Console.WriteLine(msg);}, Microsoft.Extensions.Logging.LogLevel.Information);
#endif}catch (Exception ex){ex = ex.InnerException ?? ex;//LogHelpter.AddLog("数据库连接异常," + ex.Message, "error_DbContext");}}public DbSet<K_department> K_department { get; set; }}
}
http://www.lryc.cn/news/503454.html

相关文章:

  • IoTDB AINode 报错,call inference 301: Error ocurred while executing inference
  • LLM之RAG实战(五十)| FastAPI:构建基于LLM的WEB接口界面
  • 项目-移动端适配的几种方案
  • HCIA-Access V2.5_2_2网络通信基础_TCP/IP协议栈报文封装
  • LSTM详解
  • 从零开始搭建Android开发环境:简单易懂的完整教程
  • 大模型运用-Prompt Engineering(提示工程)
  • CMake简单使用(二)
  • 攻防世界安卓刷题笔记(新手模式)1-4
  • 发现一个对话框中的按钮,全部失效,点击都没有任何反应,已经解决
  • MyBatisPlus实现多表查询
  • 机器学习详解(5):MLP代码详解之MNIST手写数字识别
  • 如何在vue中实现父子通信
  • PHP实现华为OBS存储
  • 嵌入式 linux Git常用命令 抽补丁 打补丁
  • Alan Chhabra:MongoDB AI应用程序计划(MAAP) 为客户提供价值
  • 【学习笔记】目前市面中手持激光雷达设备及参数汇总
  • Burp与小程序梦中情缘
  • 数据结构:Win32 API详解
  • 迁移学习中模型训练加速(以mllm模型为例),提速15%以上
  • socket编程UDP-实现停等机制(接收确认、超时重传)
  • 前端面试题目 (Node.JS-Express框架)[二]
  • 防范TCP攻击:策略与实践
  • 3D 生成重建034-NerfDiff借助扩散模型直接生成nerf
  • 分布式 Paxos算法 总结
  • 我的宝贵经验
  • geoserver 瓦片地图,tomcat和nginx实现负载均衡
  • Jenkins 启动 程序 退出后 被杀死问题
  • SEGGER | 基于STM32F405 + Keil - RTT组件01 - 移植SEGGER RTT
  • 分布式开发学习