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