我必須升級當前的SQL Server Compact文件以用於SQL Server Compact 4.0版。所以我使用以下代碼將SQL Server Compact 3.5版文件升級到4.0。
public static void Upgrade(string fileName, string password)
{
if (String.IsNullOrEmpty(fileName) || password == null)
throw new Exception("Unable to create connection string because filename or password was not defined");
try
{
var connectionString = string.Format(@"Data source={0};Password={1}", fileName, password);
var engine = new SqlCeEngine(connectionString);
engine.Upgrade();
}
catch (Exception ex)
{
throw (ex);
}
}
需要允許SQL Server Compact 4.0與實體框架一起使用。要安裝EntityFramework.SqlServerCompact,在Package Manager控制檯
運行以下命令來安裝,包裝EntityFramework.SqlServerCompact -Version 4.1.8482.2
你真正閱讀的知識庫文章,該錯誤信息點?它提供了採取解決這個問題的步驟。 –
是的。我經歷了[this](https://support.microsoft.com/en-au/help/974247/fix-you-receive-an-error-message-when-you-run-a-sql-server-compact -3.5-based-application-after-you-install-the-32-bit-version-of-sql-server-compact-edition-3.5-service-pack-2-on-an-x64-computer)文章。沒有幫助。 –
我創建了小型控制檯應用程序來檢查問題。控制檯應用程序可以與SQL Server CE 3.5一起使用。但它從來不適用於SQL Server CE 4.0。無論我使用X86還是ANYCPU。所以我認爲是與SQL Server CE 4.0相關的東西。首先需要找出答案。 –