Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guid.NewGuid cannot be used #2329

Closed
zgcwkj opened this issue Apr 15, 2022 · 2 comments
Closed

Guid.NewGuid cannot be used #2329

zgcwkj opened this issue Apr 15, 2022 · 2 comments

Comments

@zgcwkj
Copy link

zgcwkj commented Apr 15, 2022

PostgreSQL 13.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
EntityFrameworkCore 6.0
Npgsql.EntityFrameworkCore.PostgreSQL 6.0.3

1.png

2.png

3.png

It's been a day and I still can't solve it. What is the problem?
How to call gen_random_uuid() instead of uuid_generate_v4()?

@roji
Copy link
Member

roji commented Apr 15, 2022

gen_random_uuid() was only introduced relatively recently (in PG 13), and the provider currently assumes PG 12 by default. You can tell so by default the Npgsql provider translates Guid.NewGuid to uuid_generate_v4. To tell the provider you're using PG 13, configure your context as follows:

.UseNpgsql(@"<connection string>", o => o.SetPostgresVersion(13, 0))

(note: in the future, please avoid posting screenshots, but rather minimal, runnable code samples and full exception details as text)

@roji roji closed this as completed Apr 15, 2022
@zgcwkj
Copy link
Author

zgcwkj commented Apr 15, 2022

Thank you so much. Sorry, I've been looking for documents for a day, maybe I'm a little anxious!
I'll take care next time, submit in text!
sincere thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants