dongwei2030 2014-09-11 23:01
浏览 51
已采纳

Doctrine不会从已经存在的实体类创建一个新表?

I have an entity defined as:

<?php
namespace Acme\myBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Acme\CoreBundle\Model\Message;

/**
 * Facebook Post
 * @ORM\MappedSuperclass
 * ORM\Table(name="acme_facebookPost")
 * ORM\Entity(repositoryClass="Acme\FacebookBundle\Entity\FacebookPostRepository")
 */
class FacebookPost extends Message
{
  // entity properties
}

This entity class was created somewhere else in my project and I just moved it here. When I run following commands to generate the entity and update my tables, it runs without error but, I can not see acme_facebookPost table in my database.

php app/console doctrine:generate:entities AcmeFacebookBundle:FacebookPost

Generating entity "Acme\FacebookBundle\Entity\FacebookPost"
  > backing up FacebookPost.php to FacebookPost.php~
  > generating Acme\FacebookBundle\Entity\FacebookPost

and then:

$ php app/console doctrine:schema:update --force
Nothing to update - your database is already in sync with the current entity metadata.

Can anyone tell me what I'm doing wrong here?

Thanks.

P.S. I need to add that I'm using annotation and there is no metadata anywhere inside my bundle.

  • 写回答

1条回答 默认 最新

  • dqcqcqwq38860 2014-09-12 00:00
    关注

    It seems that you forgot to add @ before ORM\Entity(... and ORM\Table(.. hence your class is not identified as an entity

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵