문제

I've tried using Entity Framework Code First and set AutomaticMigrationsEnabled to true so that when I change the model classes the database would automatically update.

Then I have a table, where I added length to one field. Example Employee.Firstname(50) -> Employee.Firstname(100). The updated was successful.

But I have entered wrong data so I want to reset the database so I execute:

update-database -targetmigration:"0" -force -verbose

But I got the ff error:
System.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated.

Currently, my solution is to delete all the tables in the database manually as well as delete all the records in __MigrationHistory, then reinstall the EntityFramework.Migrations via NuGet.

Is there an easy way to do it?

도움이 되었습니까?

해결책

I've solved this problem by updating to EntityFramework.Migrations version 0.8.0.0.0.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top