首页 > 解决方案 > Linq2DB T4 代码生成缺少 SQLite.Interop.dll

问题描述

我将 Nuget 包 System.Data.SQLite 和 Linq2DB.SQLite 添加到我的项目中,我可以编译和运行一个简单的控制台应用程序,在 sqlite3 db 文件上执行一些测试 sql,没有任何问题。

但是,当我尝试使用 T4 模板为我的表生成 .cs 代码时,出现错误

运行转换:System.DllNotFoundException:无法加载 DLL 'SQLite.Interop.dll':找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)

来自 DataModel.ttinclude 文件。

构建项目后,在调试文件夹下正确生成了带有相关 SQLite.Interop.dll 文件的 x64/x86 文件夹。

这是我非常简单的 .tt 文件

<#@ template language="C#" debug="True" hostSpecific="True" #>
<#@ output extension=".generated.cs"                        #>
<#@ include file="$(LinqToDBT4SQLiteTemplatesPath)LinqToDB.SQLite.Tools.ttinclude" once="true" #>
<#@ include file="$(LinqToDBT4SQLiteTemplatesPath)PluralizationService.ttinclude"  once="true" #>

<#
    NamespaceName = "DataModel";

    LoadSQLiteMetadata(@"C:\DB", "Test.db");
    GenerateModel();
#>

我试图将所有可能的汇编指令添加到我的 .tt 和 DataModel.ttinclude 文件中,但没有成功。

标签: c#sqlitelinq2db

解决方案


推荐阅读