如何在MySQL中使用Fluent Migrator自动生成UUID / GUID?

问题描述 投票:1回答:1

我正在尝试将默认值NewGuid()设置为MySQL 5.7中的UUID / GUID列(.Net Core中具有FluentMigrator)。

Create.Table("table")
.WithColumn("auto_guid").AsGuid().NotNullable().WithDefaultValue(SystemMethods.NewGuid)

应基于Fluent MigratordocumentationNewGuid,但出现错误:

“您的SQL语法有误;请查看与您的MySQL服务器版本相对应的手册,以在...附近使用正确的语法。”

我搜索了任何类似的问题和解决方案,但找不到任何。

甚至可以通过Fluent Migrator在MySQL中自动生成UUID / GUID吗?

mysql asp.net-core uuid guid fluent-migrator
1个回答
0
投票

您使用的方法错误。使用.WithDefault(SystemMethods.NewGuid)代替.WithDefaultValue()

© www.soinside.com 2019 - 2024. All rights reserved.