我正在尝试使用格式yml添加列到现有表。添加新列 输入.yml文件并运行命令以生成实体
php app/console doctrine:generate:entities PLibBundle:Contact
通过运行此错误
“没有为实体指定标识符/主键”
这是我的yml文件:
Application\PLibBundle\Entity\Contact: type: entity table: null fields: id: type: integer length: null precision: 0 scale: 0 nullable: false unique: false id: true generator: strategy: IDENTITY firstName: type: string length: 255 precision: 0 scale: 0 nullable: false unique: false lastName: type: string length: 255 precision: 0 scale: 0 nullable: false unique: false companyText: type: string length: 255 precision: 0 scale: 0 nullable: true unique: false email: type: string length: 255 precision: 0 scale: 0 nullable: true unique: true hasCustomHeadshot: type: boolean length: null precision: 0 scale: 0 nullable: false unique: false createdOn: type: datetime length: null precision: 0 scale: 0 nullable: false unique: false updatedOn: type: datetime length: null precision: 0 scale: 0 nullable: false unique: false oneToOne: address: targetEntity: Application\PLibBundle\Entity\Address cascade: - remove - persist mappedBy: null inversedBy: null joinColumns: addressId: referencedColumnName: id orphanRemoval: true oneToMany: phoneNumberAssociations: targetEntity: Application\PLibBundle\Entity\ContactPhoneNumberAssociation cascade: - remove - persist mappedBy: contact inversedBy: null orphanRemoval: true orderBy: null subscriptionAssociations: targetEntity: Application\PLibBundle\Entity\ContactSubscriptionAssociation cascade: - remove - persist mappedBy: contact inversedBy: null orphanRemoval: true orderBy: null manyToOne: company: targetEntity: Application\PLibBundle\Entity\Company cascade: { } mappedBy: null inversedBy: null joinColumns: companyId: referencedColumnName: id orphanRemoval: false lifecycleCallbacks: prePersist: - beforePersist preUpdate: - beforeUpdate
答案 0 :(得分:4)
异常信息几乎解决了这个谜团,你有这样的事吗?
Contact:
type: entity
id:
id:
type: integer
generator:
strategy: AUTO
fields:
name:
type: string
length: 100
答案 1 :(得分:1)
你没有" id"键入您的配置。
你有:
Application\PLibBundle\Entity\Contact:
type: entity
table: null
fields:
id:
应该是:
Application\PLibBundle\Entity\Contact:
type: entity
table: null
id:
id: