将实体框架模型与 MySQL 服务器结合使用需要执行哪些步骤?

发布于 2024-11-26 02:08:20 字数 278 浏览 3 评论 0 原文

我添加并设计了 ADO.NET 实体数据模型 (.edmx),并生成了相应的 DDL 脚本 (.edmx.sql)。当我使用 SQL Server 2008 时,我所要做的就是通过 Transact-SQL 编辑器工具栏连接到它并执行 SQL。然而,当我尝试此方法时,它不允许我连接到 MySQL 服务器,因为它似乎只查找 Microsoft SQL Server。我有最新版本的 Connector/Net,可以将 MySQL 数据库添加为数据连接,但无法执行我需要的脚本。将实体框架模型与我的 MySQL 服务器结合使用需要执行哪些步骤?

I've added and designed an ADO.NET Entity Data Model (.edmx) and have generated the corresponding DDL Script (.edmx.sql). When I was using SQL Server 2008, all I had to do was connect to it via the Transact-SQL Editor toolbar and execute the SQL. When I try this method, however, it doesn't let me connect to the MySQL server, as it seems to be looking only for Microsoft SQL Servers. I have the latest version of Connector/Net, and can add the MySQL database as a Data Connection, but cannot execute the script I need. What steps are needed to use an Entity Framework model with my MySQL server?

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

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

发布评论

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

评论(1

止于盛夏 2024-12-03 02:08:20

我在编辑数据模型时偶然发现了这个小属性:

DDL Generation Property

(此选项与 Connector/Net。)

更改为SSDLToMySQL.tt后,右-单击并选择像平常一样从模型生成数据库...。这将生成 .edmx.sql 文件,并且应该会给出几个错误(因为 .NET 使用 SQL Server 来解析 .sql 文件。)生成 DDL 脚本后,我打开 MySQL Workbench 并将脚本粘贴进去。您需要确保已经有一个适当命名的模式存在于服务器上,然后运行脚本,瞧。

I stumbled across this little property while editing my Data Model:

DDL Generation Property

(This option was installed along side Connector/Net.)

After changing to SSDLToMySQL.tt, right-click and select Generate Database from Model... as you would normally. This will generate the .edmx.sql file, and should give you several errors (as .NET uses SQL Server to parse .sql files.) After generating the DDL script, I opened up MySQL Workbench and pasted the script in. You need to make sure that an appropriately-named schema already exists on the server, then run the script, and voila.

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