我正在尝试这种代码优先的方法,但我现在发现System.Decimal类型的属性被映射到decimal(18,0)类型的sql列.
如何设置数据库列的精度?
我正在尝试为.Net程序集创建NuGet程序包,它会对原生的win32 dll进行pinvoke.我需要将程序集和本机dll打包,并将程序集添加到项目引用中(此部分没有问题),并且应将本机dll复制到项目输出目录或其他相关目录中.
我的问题是:
我正在尝试使用SQLite实体框架.我将问题集成到我的主应用程序中时遇到了问题,因此我从头开始进行了一些测试,完全按照http://brice-lambson.blogspot.com/2012/10/entity-framework-on-sqlite.html上的说明进行操作.
毕竟说完了,运行项目时出现以下错误:
没有为ADO.NET提供程序找到具有不变名称"System.Data.SQLite"的实体框架提供程序.确保提供程序已在应用程序配置文件的"entityFramework"部分中注册.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=260882.
我的app.config看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description="Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="ChinookContext"
connectionString=
"Data Source=|DataDirectory|Chinook_Sqlite_AutoIncrementPKs.sqlite"
providerName="System.Data.SQLite" />
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
然后我看到他关于实体框架6的帖子.虽然这不是我得到的确切错误,但我尝试通过NuGet安装他更新的提供程序.错误消失了,但取而代之的是:
无法加载文件或程序集'System.Data.SQLite.Linq,Version = 2.0.88.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040) …
使用NuGet的EF6和SQLite的最新版本.我终于得到app.config文件在Stackoverflow上的一些有用的帖子后工作.现在问题是虽然数据库是,但是没有创建表.
我的app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite"
type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)"
invariant="System.Data.SQLite.EF6"
description=".Net Framework Data Provider for SQLite (Entity …Run Code Online (Sandbox Code Playgroud) .net sqlite system.data.sqlite ef-code-first entity-framework-6
我尝试将表单EF 3.5迁移到6(使用SQLite作为数据库).我们无法在app配置文件中设置连接字符串(这对ef6没有问题).我们必须在运行时以编程方式设置连接字符串(在用户选择SQLite文件之后).
这是我们的app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="testContext" connectionString="data source=Data\testdb.sqlite;Foreign Keys=True"
providerName="System.Data.SQLite" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="System.Data.SQLite" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories> …Run Code Online (Sandbox Code Playgroud) 我正在从Visual Studio 2013社区版中为我的wpf应用程序创建一个clickonce安装程序.此应用程序使用localdb.如果我手动安装sqlserver express 2014 LocalDB,它在目标机器上运行正常.
但我想在我的clickonce部署中包含SQL Server Express 2014 LocalDB的安装程序.
但是,当我打开先决条件对话框时,只有SQL Server 2012 Express LocalDB可用(参见图像).我尝试选择'2012,但它与我的安装程序放入数据文件夹的mdf文件不兼容.
问题是:如何将SQL Server Express 2014 LocalDB安装程序作为先决条件包括在内?有没有办法将MSI文件放在某处并使其工作?或者更容易坚持'2012?

clickonce prerequisites localdb visual-studio-2013 visual-studio-2015
BackgroundWorker和之间有什么区别Thread?在我的应用程序中,我使用的是一个定期与数据库通信的消息传递系统.我想在这里使用哪一个:BackgroundWorker或者Thread?
我有一个解决方案,packages文件夹检查到源代码管理.我改变了一些项目以使用project.json文件而不是packages.config定义依赖项.这些项目都是正常.csproj项目,而不是DNX .xproj项目.一切似乎都正常工作但是在更新包后我注意到新版本没有添加到解决方案的packages文件夹中.相反,它被添加到用户配置文件文件夹中的NuGet新共享包文件夹中.
所以问题是,如何让NuGet使用解决方案的packages文件夹而不是共享文件夹?
到目前为止我尝试过的方法没有成功:
global.json在解决方案文件夹中添加文件指定"packages": "packages"<add key="disableSourceControlIntegration" value="false" />在.nuget\nuget.configversion-control nuget nuget-package-restore visual-studio-2015 project.json
我正在尝试使用SignTool.exe在项目构建期间签署我的程序集和设置文件.根据这个答案,我想使用该/sha1选项,这样我就不需要指定证书密码了.但是,当我这样做时,我收到"无效的SHA1哈希格式"错误.我已尝试从MSBuild Exec任务,Visual Studio开发人员命令提示符和批处理文件都具有相同的错误.
我正在尝试的命令(显然使用不同的键):
signtool.exe sign /a /sha1 ?1234567890abcdef1234567890abcdef12345678 /tr http://timestamp.comodoca.com /td SHA256 /v Setup.msi
Run Code Online (Sandbox Code Playgroud)
我认为我的证书安装正确且SHA1密钥正确,因为它正确地与SignFile MSBuild任务一起使用.我只是使用它,但我还需要能够签署我的安装程序文件,这些文件不是用MSBuild构建的,因此需要从批处理脚本中签名.
那可能是什么问题,我该如何解决?
使用64位程序时System.Data.SQLite抛出以下EntryPointNotFoundException:
无法在DLL"SQLite.Interop.dll"中找到名为"sqlite3_changes_interop"的入口点.
奇怪的是,只有Foreign Keys=True在连接字符串中指定并且更重要的是仅在我显示之后才会出现FolderBrowserDialog.我正在浏览一个文件夹来显示要加载的数据库.
以下代码显示问题:
public Form1()
{
InitializeComponent();
// Exception below if this is displayed
using (var diag = new FolderBrowserDialog())
{
diag.ShowDialog(this);
}
var conn = new SQLiteConnection("data source=':memory:'");
conn.Open(); // Works fine
conn.Close();
// No exception below if displayed here instead
//using (var diag = new FolderBrowserDialog())
//{
// diag.ShowDialog(this);
//}
conn = new SQLiteConnection("data source=':memory:';foreign keys=True");
conn.Open(); // EntryPointNotFoundException thrown here
conn.Close();
}
Run Code Online (Sandbox Code Playgroud)
foreign keys=True如果未显示对话框,或者在打开任何其他SQLite连接后显示对话框,则打开连接可正常工作.如果程序作为32位进程运行,代码也可以正常工作.如果我使用单一混合模式x64 SQLite程序集或MSIL + x64互操作程序集,行为也是相同的.我正在使用v1.0.92.0所以这不是问题.
所以问题是为什么会显示 …
.net ×6
sqlite ×4
c# ×3
nuget ×2
64-bit ×1
batch-file ×1
clickonce ×1
code-signing ×1
decimal ×1
localdb ×1
msbuild ×1
nuget-spec ×1
project.json ×1
runtime ×1
signtool ×1