如何在 Mac 上使用 DbLinq SqlMetal for MySQL?

发布于 2024-10-20 00:34:52 字数 420 浏览 1 评论 0原文

我在 Mac OS 上使用 Mono/MonoDevelop,并且想要一个使用 SqlMetal(Mono 附带的 DbLinq 版本)与 MySQL 数据库进行 LINQ-to-SQL 的示例。

奇怪的是,我发现了很多 SQLite 的示例,但没有找到 MySQL 的示例。发现MySQL的例子似乎是指微软的SqlMetal.exe。

我尝试安排 SQLite 中的 sqlmetal 命令以使其适用于 MySQL,但我收到以下消息:

sqlmetal:无法加载databaseConnectionType类型“ByteFX.Data.MySqlClient.MySqlConnection,ByteFX.Data”。尝试使用 --with-dbconnection=TYPE 选项。

感谢帮助!谢谢。

I'm using Mono/MonoDevelop on Mac OS, and I want an example for using SqlMetal (DbLinq version included with Mono) for LINQ-to-SQL with MySQL database.

Oddly, I found many examples for SQLite, but none for MySQL. Examples found for MySQL seems to refer to the Microsoft's SqlMetal.exe.

I tried to arrange my sqlmetal command from SQLite to adapt it for MySQL, but I have this message:

sqlmetal: Could not load databaseConnectionType type 'ByteFX.Data.MySqlClient.MySqlConnection, ByteFX.Data'. Try using the --with-dbconnection=TYPE option.

Help is appreciated! Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

天涯沦落人 2024-10-27 00:34:52

查找并编辑 sqlmetal.exe.config,并将设置替换为不使用 ByteFX(长期不受支持)并使用 MySql.Data。

请记住包含完全限定的程序集名称,在我的情况下,该行如下所示:

provider name="MySQL" dbLinqSchemaLoader="DbLinq.MySql.MySqlSchemaLoader, System.Data.Linq, Version=3.5.0.0, Culture=neutral ,PublicKeyToken = b77a5c561934e089”databaseConnection =“MySql.Data.MySqlClient.MySqlConnection,MySql.Data,版本= 6.2.3.0,文化=中性,PublicKeyToken = 2f3544035097bf97”

(我已经使用该版本和令牌安装了 MySql Connector)

问候

Find and edit your sqlmetal.exe.config and replace the settings not to use ByteFX (LONG unsupported) and use MySql.Data.

Remember to include the fully qualified assembly name, in my case that line looks like:

provider name="MySQL" dbLinqSchemaLoader="DbLinq.MySql.MySqlSchemaLoader, System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" databaseConnection="MySql.Data.MySqlClient.MySqlConnection, MySql.Data, Version=6.2.3.0, Culture=neutral, PublicKeyToken=2f3544035097bf97"

(I have MySql Connector installed with that version and token)

Regards

筱果果 2024-10-27 00:34:52
  1. 按照 http://www.mono-project.com/MySQL 下载并安装 MySQL Connector/Net

    cd path_to_MySql.Data.dll 程序集
    gacutil -i MySql.Data.dll
    
  2. 浏览到 /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/MySql.Data (或更改版本编号以匹配您正在使用的版本),您应该会看到诸如 6.6.5.0__c5687fc88969c44d

    之类的目录,

  3. 打开 /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/4.0/sqlmetal.exe.config (或您正在使用的版本的等效项)并编辑 <根据 BlackR2D 的答案,使用步骤 2 中文件夹中的属性,例如 Version=6.6.5.0< /code> 和 PublicKeyToken=c5687fc88969c44d

  4. 确保您正在运行的项目的路径没有空格,否则您可能会收到“MonoDevelop.Database.Sql.SqlMetalExecException:sqlmetal:找不到文件”错误

  5. 当您选择“生成 Linq 类”时,将语言更改为 C# 而不是 C#2,否则您可能会收到“MonoDevelop.Database” .Sql.SqlMetalExecException:sqlmetal:对象引用未设置为对象的实例'错误

然后我可以生成Output.cs,但如果尝试生成DBML(Output.dbml)仍然会收到错误:

'MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Access to the path "//Output.dbml" is denied'
  1. Download and install MySQL Connector/Net as per http://www.mono-project.com/MySQL

    cd path_to_your MySql.Data.dll assembly
    gacutil -i MySql.Data.dll
    
  2. Browse to /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/MySql.Data (or change the version number to match the version you're using) and you should see directories such as 6.6.5.0__c5687fc88969c44d

  3. Open /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/4.0/sqlmetal.exe.config (or equivalent for the version you're using) and edit the databaseConnection attribute of the <provider name="MySQL" node as per BlackR2D's answer, using the properties from the folder in step 2 e.g. Version=6.6.5.0 and PublicKeyToken=c5687fc88969c44d

  4. Make sure the path to the project you're running doesn't have a space in it or you may get a 'MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Could not find file' error

  5. When you select 'Generate Linq Class' change the language to C# rather than C#2 otherwise you may get a 'MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Object reference not set to an instance of an object' error

I can then generate Output.cs, but still get an error if trying to generate DBML (Output.dbml):

'MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Access to the path "//Output.dbml" is denied'
乖乖公主 2024-10-27 00:34:52

我在 mono 2.10.2 上得到了这个工作:

[mono-] ~ @ sqlmetal /namespace:MonoService /provider:MySql "/conn:Server=[server];Database=[db];Uid=[name];Pwd=[pass];" /code:ProxyContext.cs --with-dbconnection="MySql.Data.MySqlClient.MySqlConnection, MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"

在将 MySql.Data 放入 gac 之前:

gacutil -i MySql.Data.dll

I got this working on mono 2.10.2:

[mono-] ~ @ sqlmetal /namespace:MonoService /provider:MySql "/conn:Server=[server];Database=[db];Uid=[name];Pwd=[pass];" /code:ProxyContext.cs --with-dbconnection="MySql.Data.MySqlClient.MySqlConnection, MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"

Before I put MySql.Data into the gac:

gacutil -i MySql.Data.dll
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文