@@ -6,7 +6,6 @@ import type {
66 Platform ,
77} from '@mikro-orm/core' ;
88import { ReferenceKind , Utils } from '@mikro-orm/core' ;
9-
109import pluralize from 'pluralize' ;
1110import { identifierForEnumValue , pascalToCamelCaseString , pascalToKebabCaseString } from '../utils' ;
1211import { BaseFile } from './base-file' ;
@@ -103,7 +102,18 @@ export class SchemaEntityFile extends BaseFile {
103102 }
104103
105104 this . coreImports . add ( 'Entity' ) ;
106- file += `@Entity<${ this . meta . className } >(${ this . quote ( this . meta . className ) } , {\n\tprovider: new MikroBackendProvider(Orm${ this . meta . className } , connection, { backendDisplayName: '${ friendlyNameForDatabaseType ( this . databaseType ) } ' }),\n})\n` ;
105+
106+ file += `@Entity<${ this . meta . className } >(${ this . quote ( this . meta . className ) } , {\n\tprovider: new MikroBackendProvider(Orm${ this . meta . className } , connection, { backendDisplayName: '${ friendlyNameForDatabaseType ( this . databaseType ) } '})` ;
107+
108+ if ( props . length === 1 && props [ 0 ] . primary ) {
109+ // Special case. If there's a single primary key field in this entity, right now that requires that it's a client side generated primary key.
110+ // There's no reason this has to be the case, but it's a current limitation, so we should generate a working project for them.
111+ // We should be able to remove this in the future and allow users to use it both ways.
112+ file += `,\n\tapiOptions: { clientGeneratedPrimaryKeys: true },\n})\n` ;
113+ } else {
114+ file += `\n})\n` ;
115+ }
116+
107117 file += `export class ${ this . meta . className } {\n` ;
108118 file += `${ classBody } }\n` ;
109119 const imports = [
0 commit comments