gpt4 book ai didi

c# - 在 Ubuntu 16.04 上使用 Entity Framework

转载 作者:行者123 更新时间:2023-11-30 14:47:14 25 4
gpt4 key购买 nike

我已经成功创建了一个托管在 Ubuntu Linux 服务器上的 asp.net core mvc 应用程序。该网站运行正常。

今天我将 Entity Framework 添加到我的项目中。我可以将数据发布到我的数据库并在我的 Windows 机器上检索它,这样就可以正常工作了。

当我将我的项目移动到我的 Ubuntu 机器上时,该网站可以正常工作,但是当我尝试访问需要我的数据库的页面时,我收到此错误:

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

我是不是在我的 Ubuntu 机器上丢失了 Entity Framework/SQL_Server 包,还是有其他原因?

最佳答案

查看错误信息:

PlatformNotSupportedException: LocalDB is not supported on this Platform.

这意味着,Linux 不支持 LocalDB。

另见 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://learn.microsoft.com/en-us/sql/linux/sql-server-linux-overview, or SQL Azure. Alternatively, you can use the Postgres and SQLite providers.

总而言之,您需要另一个数据库。

关于c# - 在 Ubuntu 16.04 上使用 Entity Framework ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46146371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com