I'm creating a simple test table with EF Core e SQlite
The first test in which modelbuilder
creates a migration
(shown just below)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Curso>()
.Property(c => c.Nome)
.HasColumnType("varchar(51)");
}
Migration snippet created by model builder above
Nome = table.Column<string>(type: "varchar(51)", nullable: true),
Second Test:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Curso>()
.Property(c => c.Nome)
.HasMaxLength(52);
}
Migration snippet created by model builder above
Nome = table.Column<string>(maxLength: 52, nullable: true),
The result of the two tests is reflected differently in the creation of the database, the first one creates a field correctly varchar(51)
and the second one creates a default field Text
I was in doubt.
It was not for the two to create the same type field varchar
?
Does it make any difference between these two properties ( HasMaxLength e HasColumnType
)?