In the previous EF, I could do this:
entityTypeBuilder
.Property(b => b.Foo)
.IsRequired()
.HasMaxLength(10)
.IsFixedLength();
That would generate a migration with something like
Foo = c.String(nullable: false, maxLength: 10, fixedLength: true)
However in EF Core there is no IsFixedLength()
.
Is there some other way of doing this?
If you want to add a new column to the database table which was already created using add-migration and update-database, one needs to again run the command (add-migration) in nuget package manager console with a new migration name (add-migration "Name2") and then run the command (update-database).
The basic shape of the model is detected by using conventions. Conventions are sets of rules that are used to automatically configure a conceptual model based on class definitions when working with Code First. The conventions are defined in the System.
For anyone coming to this issue like I did earlier today if you are looking for the IsFixedLength() function it is an extension method on the RelationalPropertyBuilderExtensions class in the Microsoft.EntityFrameworkCore.Relational package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With