Add migration with different assembly

All EF commands have this check: if (targetAssembly != migrationsAssembly) throw MigrationsAssemblyMismatchError; targetAssembly = the target project you are operating on. On the command line, it is the project in the current working directory. In Package Manager Console, it is whatever project is selected in the drop down box on the top right of that … Read more

EF Migrations: Rollback last applied migration?

I want to add some clarification to this thread: Update-Database -TargetMigration:”name_of_migration” What you are doing above is saying that you want to rollback all migrations UNTIL you’re left with the migration specified. Thus, if you use GET-MIGRATIONS and you find that you have A, B, C, D, and E, then using this command will rollback … Read more

Possible to default DateTime field to GETDATE() with Entity Framework Migrations?

You can use DateCreated = c.DateTime(nullable: false, defaultValueSql: “GETDATE()”) Usage: public partial class MyMigration : DbMigration { public override void Up() { CreateTable(“dbo.Users”, c => new { Created = c.DateTime(nullable: false, defaultValueSql: “GETDATE()”), }) .PrimaryKey(t => t.ID); … Update 2012-10-10: As requested by Thiago in his comment, I add a little extra context. The code … Read more

MVC3 and Code First Migrations – “model backing the ‘blah’ context has changed since the database was created”

From my experience that suggests that migration table is out of sync (even if your data isn’t), and that’s been part of the db schema now (since 4.3 I think – under system tables). There could be many reasons and ways to experience that error , but most of the time… The problematic part is … Read more

There is already an object named in the database

it seems there is a problem in migration process, run add-migration command in “Package Manager Console”: Add-Migration Initial -IgnoreChanges do some changes, and then update database from “Initial” file: Update-Database -verbose Edit: -IgnoreChanges is in EF6 but not in EF Core, here’s a workaround: https://stackoverflow.com/a/43687656/495455

Oracle.ManagedDataAccess.EntityFramework – ORA-01918: user ‘dbo’ does not exist

I had the same problem and it was resolved by Thiago Lunardi’s response. Thank you. I didn’t have enough reputation to vote up your response. To mention here, I succeeded after setting my schema name in UPPERCASE. Put this in your Context file under your new dbContext class, like this: public partial class MyAppContext : … Read more