Closed alprinias closed 3 years ago
Answering my own question, I had made the relationship 1 to many, whereas it should be 0/1 to many. Then the AddColumn in the migration is pproduced as nullable and without a default value. However, I can't see what actually is the difference in the code-first class that tells the migration to add the nullable attribut or not.
Best, Alex
Migrations aren't under the designer's control. But required associations (e.g., 1..*) will always migrate the foreign key, be it shadow or declared, as a required property. If that's a value type, like Guid is, it'll be a nullable type or not.
Hi,
I'm trying to insert a Bidirectional relationship on the same table (parent-children type relationship), one to many, optional, i.e. there can be records with no parent. The parent_id column is produced by the designer as Guid?, which is correct, however when translated in the migration it gives me an AddColumn with
nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
I would expect it to be nullable: true with no default value.
Am I missing something? Does this happen for Guid columns only?
Thank you, Alex