unable_to_create_user error
I just try to create a user with Github using prisma and i got this error , my shcema is good and relation with db as well .

16 Replies

try running npx prisma generate
I already tried it :/
ok I have read it somewhere, its a Prisma specific thing. You should have a
user
schema with you before you run npx prisma generate
so the flow goes like this
- create a user
schema
- npx prisma generate
@San once you ran it, do the tables appear in your db?wait i try
Here i have model

You dont talk about that ?
@San can you share the complete erro log?
yep
○ Compiling / ...
✓ Compiled / in 1297ms
GET / 200 in 1553ms
○ Compiling /api/auth/[...all] ...
✓ Compiled /api/auth/[...all] in 617ms
POST /api/auth/sign-in/social 200 in 1490ms
GET / 200 in 185ms
POST /api/auth/sign-in/social 200 in 58ms
2025-05-17T16:14:11.871Z ERROR [Better Auth]: PrismaClientValidationError:
Invalid
GET /api/auth/error?error=unable_to_create_user 200 in 74ms
db[model].create()
invocation in
C:\Users\picot\Desktop\school.next\server\chunks\a78f2_better-auth_dista7efb35e..js:10126:44
10123 if (!db[model]) {
10124 throw new TURBOPACKimportedmodule$5b$project$5d2f$node_modules$2f2e$pnpm$2f$better$2d$auth$40$1$2e$2$2e$8$2f$node_modules$2f$better$2d$auth$2f$dist$2f$shared$2f$better$2d$auth$2e$DdzSJf$2d$n$2e$mjs$5b$app$2d$route$5d$$28$ecmascript$29$__["B"](Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'
);
10125 }
→ 10126 return await db[model].create({
data: {
name: "Mathis",
email: "[email protected]",
emailVerified: true,
~~~~
image: "https://avatars.githubusercontent.com/u/144937694?v=4",
createdAt: new Date("2025-05-17T16:14:11.861Z"),
updatedAt: new Date("2025-05-17T16:14:11.861Z"),
id: "EYfR2SE59o1OuQRsOjePlJsULGgbiepc"
},
select: undefined
})
Argument emailVerified
: Invalid value provided. Expected DateTime or Null, provided Boolean.
2025-05-17T16:14:11.872Z ERROR [Better Auth]: unable_to_create_user
GET /api/auth/callback/github?code=bf3bdb43c8b77b737e2b&state=fKUyJDGg53hTVqkmu3V_SiICpzeI4ksp 302 in 811msGET /api/auth/error?error=unable_to_create_user 200 in 74ms
I tried with google as well but i got an other error
Seems like either you didn't generate the schema well (maybe some of the fields might have mapped to a different field type than what's expected by better-auth) or you didn't migrate your generated schema. Try doing one of those. Check if all the field types in the existing db match the one listed in the schema. if any of the field you have added, that should be added in the user object while instantiating better-auth
https://www.better-auth.com/docs/concepts/database
https://www.better-auth.com/docs/concepts/typescript#additional-fields
Database | Better Auth
Learn how to use a database with Better Auth.
TypeScript | Better Auth
Better Auth TypeScript integration.
Re:
I try all of these and nothing work , so i try to create a new fresh app
and i have the same issue
it's strange
The primary error is because of the emailVerified field. better-auth expects the emailVerified to be a boolean while you have given it to be DateTime, change it to boolean and then generate and then migrate.
better-auth generate might have warned you of this while you generated the scripts. See if you see any warnings when you do generate or migrate.
I do that but now i have provider and type not defined for my Account Table , you cant une better auth like
providerAccoundId as well
and after id
i can't do anything
Yeah. that is the worst part of this database integrations. the types that better-auth expects and the types the fields in the table initialize is completely different. So you have to manually scope the fields to what the better-auth expects. Those details will be given as warnings when you try to migrate. These details are specific to databases, so it might differ. try exactly giving the field types what better-auth expects to the fields you have given in prisma (database specific). it takes some couple of tries but you will get it.