title: Attempted to call an undefined method named "setName"
body: <p>I couldn't persist an object to the database.</p>
  <p>This is the error:<br />
  <a href="https://i.stack.imgur.com/VXLIy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VXLIy.png" alt="link to error" /></a></p>
  <p>This is the DefaultController which is situated on AppBundle\Controller:</p>
  <pre><code>&lt;?php
  
  namespace AppBundle\Controller;
  
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  use AppBundle\Entity\Product;
  class DefaultController extends Controller
  {
      /**
       * @Route(&quot;/&quot;, name=&quot;homepage&quot;)
       */
      public function indexAction(Request $request)
      {
          // replace this example code with whatever you need
          return $this-&gt;render('default/index.html.twig', [
              'base_dir' =&gt; realpath($this-&gt;container-&gt;getParameter('kernel.root_dir').'/..'),
          ]);
      }
  /**
   * @Route(&quot;/content&quot;, name=&quot;db&quot;)
   */
      public function createAction()
      {
          $product = new Product();
          $product-&gt;setName('A Foo Bar');
          $product-&gt;setPrice('19.99');
          $product-&gt;setDescription('Lorem ipsum dolor');
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($product);
          $em-&gt;flush();
          return new Response('Created product id '.$product-&gt;getId());
      }
  }
  </code></pre>
  <p>And this is the Product entity on AppBundle\Entity with the field name:</p>
  <pre><code>namespace AppBundle\Entity;
  use Doctrine\ORM\Mapping as ORM;
  /**
   * @ORM\Entity
   * @ORM\Table(name=&quot;product&quot;)
   */
  class Product
  {
      /**
       * @ORM\Column(type=&quot;integer&quot;)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)
       */
      protected $id;
      /**
       * @ORM\Column(type=&quot;string&quot;, length=100)
       */
      protected $name;
      /**
       * @ORM\Column(type=&quot;decimal&quot;, scale=2)
       */
      protected $price;
      /**
       * @ORM\Column(type=&quot;text&quot;)
       */
      protected $description;
      
  
      /**
       * Get id
       *
       * @return integer
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  }
  </code></pre>