Change of MaxLength not migrated to DB #3434
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
I'm using beta8. So I don't think this is a dupe of #882, but maybe a followup on it.
I followed the steps given here.
If I do ...
... and run the initial migration, I get a Blog table with a column defined as
Url (nvarchar(256), not null
, as I would expect.If I subsequently change this to ...
... and do
Add-Migration
/Update-Database
, the field stays as it was in the db, even though the change inHasMaxLength
is present in theModelSnapshot
class:If the only thing I change for the second migration is the value for
HasMaxLength
as done above, I get the following Migration code:Which probably is the reasony why the database isn't changed. If I manually change this to ...
... applying and reverting the second migration works as expected.
I assume it's a bug that a change of MaxLength in the model is not migrated to the database? Because if I remove the
.IsRequired()
from the model, the column is altered as it should be if I run the migration, so subsequent column changes actually do seem to work. If I modify two properties at once (ie. changeIsRequired()
andHasMaxLength
), only the change of the first one is migrated to the db.The text was updated successfully, but these errors were encountered: