title: EF Core - Change column type from varchar to uuid in PostgreSQL 13: column cannot be cast automatically to type uuid
body: <h2>Before:</h2>
  <pre><code>public class MyEntity
  {
      public string Id { get; set; }
      //...
  }
  </code></pre>
  <p><strong>Config:</strong></p>
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      //...
  
      modelBuilder.Entity&lt;MyEntity&gt;()
          .Property(e =&gt; e.Id)
          .ValueGeneratedOnAdd();
  }
  </code></pre>
  <p>This was the previous developer's code which resulted in GUID values for the column. But in C# I had to deal with strings, so I decided to change the model.</p>
  <h2>After:</h2>
  <pre><code>public class MyEntity
  {
      public Guid Id { get; set; }
      //...
  }
  </code></pre>
  <p>And I removed the <code>ValueGeneratedOnAdd()</code> code from Fluent API config.</p>
  <p>I get the <code>column &quot;Id&quot; cannot be cast automatically to type uuid</code> error.</p>
  <p>I think the key in this message is the <code>automatically</code> word.</p>
  <p>Now my question is that since the values on that column are already GUID/UUID, is there any way to tell Postgres to change the <code>varchar</code> type to <code>uuid</code> and cast the current string value to UUID and put it in the column? I'm guessing there should be a SQL script that can do this without any data loss.</p>