FAQ Database Discussion Community


How do you perform a rollback when using MigrateDatabaseToLatestVersion

entity-framework,ef-code-first,code-first-migrations,ef-migrations
With EF Migrations you can add migration scaffoldings and then keep running 'Update-Database' to apply changes. And in order to rollback the following works: Update-Database -TargetMigration: <xyzMigration> This is great for updating your dev. DB. However when I automate migrations using MigrateDatabaseToLatestVersion for deploying to other environments like test and...

Deploying to Azure not running EF Code First Migrations

entity-framework,azure,ef-code-first,code-first-migrations,ef-migrations
I am running Entity Framework with Code First Migrations. My new release adds a table, modifies a few tables, and run some scripts. This works perfectly when developing locally using update-database. Upon deployment the new table was not created and I was receiving errors from my client. I attached the...

One-to-Many relation to existed table in EF6: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint

sql,.net,sql-server,entity-framework,ef-migrations
So now I'm trying to use Code first approach with a couple of existed tables. So before now I have an existed table with model: [Table("Existed1")] public class TimeSerieEntity { [Key] [Column(Order = 0)] [StringLength(3)] public string TsId { get; set; } [Key] [Column(Order = 1, TypeName = "date")]...

Why is AutomaticMigrationsDisabledException thrown?

entity-framework,entity-framework-6,ef-migrations
We have An Old Web Project A New Web Project A Class Library containing all Entity Framework code All three projects reference Entity Framework 6.1.3. The Class Library is shared by Old Web Project and New Web Project. Both web projects have a file reference to Class Library. They both...

Migrate entity with updated DatabaseGeneratedOption in Entity-Framework

c#,entity-framework,ef-migrations
I have created code-first app according to this article - Code First to a New Database. Now I am going to change DatabaseGeneratedOption for Blog.BlogId. I changed my code in next way: public class Blog { [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public int BlogId { get;set; } ... } And created migration for...