0

当我通过这个 php 应用程序/控制台学说更新数据库时:schema:update --force 它给出了下面给出的异常 MappingException: Duplicate definition of column 'email' on entity 'Dashboard\UserBundle\Entity\User' in a field或鉴别器列映射我的 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
}
}

如何删除此异常?

4

1 回答 1

2

删除 $email 和他的 getter 和 setter

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

它已经在 BaseUser

于 2013-08-20T12:17:03.060 回答