Questions tagged [automatic-migration]

Automatic migrations is a feature of Entity-Framework Code-First approach.

Automatic migrations is a feature of Entity-Framework Code-First approach. Entity-Framework identifies changes in model and updates database if there are no risks of data loss.

16 questions
7
votes
1 answer

EF - Default value for new column with automatic migration

I use EF code first and automatic migrations. I want to add a new column to my model - a boolean column to present "active" (true) or "inactive" (false). How can I add this column and set a default value ("true") for the rows that already in the DB…
5
votes
1 answer

Entity Framework automatic migrations enabled does not work

I have this db configuration public class AppDbContext : DbContext { public AppDbContext(string connectionStringOrName) : base(connectionStringOrName) { Database.SetInitializer(new AppDbInitializer()); …
3
votes
1 answer

ASP.NET MVC 4 Code-First IdentityUserRole with additional primary key 3-way-relation

I have been searching the web for weeks in hope of finding a solution to an issue I'm having when using the .NET Identity framework to create my database. One of the closest related issues i found is this: Customised IdentityUserRole primary…
3
votes
2 answers

Adding foreign key with new table with automatic migrations entity framework mvc c#

I would like to add a new table and a foreign key of an existing table in SQL Server with code first automatic migrations. The only problem I have is that there is data in the table and I can't set the foreign key to a default value for existing…
2
votes
1 answer

How to generate migrations automatically from Sequelize models

I just started to program with node.js. I needed an ORM so I used Sequelize library. I wrote my User model as follows and I need to create a migration for it. Is there any way to create migrations automatically from the Sequelize models instead of…
1
vote
2 answers

Android Room automatic-migrations?

Is there a way of doing an automatic migration when needed with Room Persistance library in Android? Like Django migrations where you just execute makemigrations and migrate and it migrates automatically. It also increments the database version. And…
1
vote
0 answers

How to force Entity Framework to apply an automatic initial migration?

I've inherited a project that uses Entity Framework. I've used EF a lot on other projects, but have never come across this issues before. In a nutshell: adding explicit migrations seems to have broken an initial automatic migration. Here's a…
1
vote
2 answers

How to describe details of an automatic migration

In Entity Framework Code-First you can enable automatic migrations based on code changes in the model. By calling Update-Database, these changes are: Registered in a [timestamp]_AutomaticMigration Generate SQL scripts and migrate database Store…
Jono
  • 3,949
  • 4
  • 28
  • 48
1
vote
1 answer

How to enable automatic migration when using custom DB initializer c#

I have created a custom database initializer so that I can override the seed method and add data to the database each time it is created using the DropCreateDatabaseIfModelChanges initializer. See code below: public class BehaviourContext :…
brian4342
  • 1,265
  • 8
  • 33
  • 69
1
vote
1 answer

EF 6 automatic migration column name uppercase rename not detected

We are using EF6 code first approach and we have automatic migrations enabled (we are at the beginning of the project). Database.SetInitializer(new MigrateDatabaseToLatestVersion()); And in the Configuration class we…
1
vote
2 answers

Automatic Migration and manual invocation of Update-Database

Do I have to manually issue the Update-Database command in the package manager console even though I have automatic migrations turned on? I'm running MVC4 and EF6. The solution is targeted for .NET 4 (I can't change this unfortunately). EDIT: I'm…
mituw16
  • 5,126
  • 3
  • 23
  • 48
0
votes
0 answers

EF6 creating automatic migrations undoing explicit migrations

I have a project that I've been developing for two years and has lots of migrations. However, I've recently had an issue with automatic migrations being created which undo my explicit migrations, meaning I can no longer build the DB properly. It…
0
votes
1 answer

Automatic Migrations when history table doesn't exist

In a team environment, we have one member with a database that already has some of the tables in the model but no Migration History table. Using EF Automatic Migrations, how do we upgrade the database so it will create the history table, add the…
Breakskater
  • 415
  • 1
  • 4
  • 18
0
votes
1 answer

Automatic Migration command not working

So I'm doing an application using the MVC5 framework, and I have the default tables from the individual user accounts. Now i am trying to add my own tables,but it doesn't seem to be working. A test class: public class teste { public…
Pedro Costa
  • 427
  • 3
  • 13
  • 31
0
votes
1 answer

Automatic Migrations Set Connection String in code .NET MVC

How to configure Entity Framework to use different connection string when executing migrations and when working with the database. The reason for that is quite simple, I do not want to have sa login for the website, but I want to be able to execute…
d.popov
  • 4,175
  • 1
  • 36
  • 47
1
2