2017-09-10 81 views
3

我成功創建了一個託管在Ubuntu Linux服務器上的asp.net核心mvc應用程序。該網站運行正常。在Ubuntu上使用實體框架16.04

今天我添加了Entity Framework到我的項目。我可以發佈數據到我的數據庫並在我的Windows機器上檢索它,所以這是行得通的。

當我將我的項目,我的Ubuntu的機器,該網站的作品,但是當我把需要我的數據庫訪問的網頁我得到這個錯誤:

PlatformNotSupportedException: LocalDB is not supported on this Platform. 
System.Data.SqlClient.SNI.LocalDB.GetLocalDBConnectionString(string localDbInstance) 

我失去了對實體框架/ SQL_SERVER包我Ubuntu機器還是有其他原因?

+0

你要使用Linux的SQL Server 2017年,所以使用MySQL或MariaDB的,其原產於那些操作系統,它的工作原理與EF7和.NET核心 – Gusman

回答

4

看看錯誤消息:

PlatformNotSupportedException: LocalDB is not supported on this Platform.

這意味着,是的LocalDB Linux不支持。

另見this issue在GitHub上:

As @ErikEJ said, LocalDB is Windows only. On Linux, you can use EF Core with a remote SQL Server (running on Windows), the preview version of https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-overview , or SQL Azure . Alternatively, you can use the Postgres and SQLite providers.

因此,在總結,你需要另一個數據庫。

1

你不能從Ubuntu的視覺工作室它不支持作爲錯誤說使用本地數據庫文件,但你可以使用SQL Server 2017年數據庫引擎其現在支持Linux或Ubuntu的

,你可在任何支持DBMS使用此鏈接安裝在Linux Installation guidance

+0

這將是一個很好的解決方案,然而,sql server 2017需要3.5GB內存才能安裝。不幸的是,我沒有那麼多的內存。 – jeninja

+0

我能夠通過使用SQLite和創建本地.db文件來解決此問題。請參閱http://jeninja.net/Links獲取一些有用的資源。 – jeninja