Hello all,
We are switching to Dotconnect for PostgreSQL from another provider (NpgSQL). We already have a live environment which built by migrations. After switching to Dotconnect for PostgreSQL migrations starts to generate type changes for existing entities like using varchar data type instead of text. It causes problems for migrations, especially for live production environment.
Now, we are curious about if there is a way to specify target data type for all specific data types. Instead of setting all entity fields with data annotation we want to use a specific database type for a data type (for example, text for all string fields)
Regards
Type changes on migration
Re: Type changes on migration
Please specify the version of Entity Framework you are working with (e.g.: EF 6, EF Core 5, etc).
With EF 6, try using conversion:
With EF 6, try using conversion:
Code: Select all
public class MyContext : DbContext {
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
modelBuilder
.Properties()
.Where(p => p.PropertyType == typeof(string))
.Configure(p => p.HasColumnType("text"));
}
// ...
}