Fos User捆绑数据库的重复定义

时间:2013-08-20 11:07:16

标签: symfony doctrine fosuserbundle

当我通过这个更新数据库时 php app / console doctrine:schema:update --force 它给出了下面给出的例外情况 MappingException:字段或标识符列映射中实体'Dashboard \ UserBundle \ Entity \ User'上的列'email'的重复定义 我的user.php在下面给出

<?php
// src/Dashboard/UserBundle/Entity/User.php

namespace Dashboard\UserBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints AS Assert;
use Dashboard\UserBundle\Entity\User;

/**
* @ORM\Entity
* @ORM\Table(name="acme_user")
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="email", column=@ORM\Column(type="string", name="email", length=255, unique=false, nullable=true)),
* @ORM\AttributeOverride(name="emailCanonical", column=@ORM\Column(type="string", name="email_canonical", length=255, unique=false, nullable=true))
* })
*/
class User extends BaseUser
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
/**
 * @ORM\Column(type="string", length=255)
 * @Assert\NotBlank()
 * @Assert\Email()
 */
protected $email;

/**
 * @ORM\Column(type="string", length=255)
 * @Assert\NotBlank()
 */
protected $Password;

public function getId()
{
    return $this->id;
}

public function getEmail()
{
    return $this->email;
}

public function setEmail($email)
{
    $this->email = $email;
}

public function getPassword()
{
    return $this->plainPassword;
}

public function setPassword($password)
{
    $this->plainPassword = $password;
}

public function __construct()
{
    parent::__construct();
    // your own logic
}
}

如何删除此例外?

1 个答案:

答案 0 :(得分:2)

删除$ email及其getter和setter

/**
 * @ORM\Column(type="string", length=255)
 * @Assert\NotBlank()
 * @Assert\Email()
 */
protected $email;

它已经在BaseUser