ef-migrations

How can I manage EF 6 migrations in visual studio 2015?

爱⌒轻易说出口 提交于 2019-11-30 02:50:58
问题 I started a new MVC project with EntityFramework -Version 6.1.2 using Visual Studio 2013 latest update. I made a couple of migrations and updated the database. After this I checked out the project on another computer and opened with Visual Studio 2015 CTP 6. If I go in the package manager console and try to run any migration commands, they're not recognized: add-migrations : The term 'add-migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check

EF 5 Code First Migration Bulk SQL Data Seeding

时间秒杀一切 提交于 2019-11-30 02:23:04
I am using EF5 with MVC4. The problem is that I have large data in my DB which I already imported from legacy DB. I want to load seed that data when model changes. My question is how can I seed large amount of data that is already in my DB? internal sealed class Configuration : MigrationsConfiguration<VoiceLab.Models.EFDataContext> { public Configuration() { AutomaticMigrationsEnabled = true; } protected override void Seed(VoiceLab.Models.EFDataContext context) { //what to do here to seed thousands or records that are already in db } } thanks, Tepu Here is how you can seed bulk data by just

adding a foreign key with Code First migration

醉酒当歌 提交于 2019-11-30 01:53:10
I have an error when trying to update my database after adding a migration. Here are my classes before add-migration public class Product { public Product() { } public int ProductId { get; set; } public string Name { get; set; } public decimal Price { get; set; } public bool Istaxable { get; set; } public string DefaultImage { get; set; } public IList<Feature> Features { get; set; } public IList<Descriptor> Descriptors { get; set; } public IList<Image> Images { get; set; } public IList<Category> Categories { get; set; } } public class Feature { public int Id { get; set; } public string Title {

Entity Framework Migrations don't include DefaultValue data annotation (EF5RC)

ε祈祈猫儿з 提交于 2019-11-30 01:39:43
问题 I have a class that looks like this: [Table("Subscribers", Schema = "gligoran")] public class Subscriber { [Key] public string Email { get; set; } [Required] [DefaultValue(true)] public bool Enabled { get; set; } } When creating a migration to include this class I get: public partial class AddSubscriberClass : DbMigration { public override void Up() { CreateTable( "gligoran.Subscribers", c => new { Email = c.String(nullable: false, maxLength: 128), Enabled = c.Boolean(nullable: false), })

EF5 Migrations - Duplicate/Re-defined variable bug when dropping constraints | Issue with usage of SQL GO command

六眼飞鱼酱① 提交于 2019-11-30 01:30:40
问题 Background: We have a project that uses ef-migrations containing multiple (read ~60) migrations created over a long period of development. Naturally, some of these migrations also involve: dropping constraints 1,2 creating triggers All is unicorns and rainbows when we run Update-Database because each migration runs as a separate batch. But when creating SQL Scripts for these migrations using Update-Database -Script we encountered a few issues as described below: Problem 1: When dropping

How to use migrations on an existing db in production created using Entity Framework 4.1?

风流意气都作罢 提交于 2019-11-30 01:25:31
I have a system in production which was created with Entity Framework 4.1 Code First. Now, I have upgraded to 4.3 and need to apply migrations, but there's several use cases I need to cover: A new developer needs the database created from scratch with seed data. (The Seed() method also applies some unique indices.) The production environment needs only the unapplied changes applied. (But keep in mind that this DB was created in EF 4.1, which doesn't have migrations.) How do I create the migrations and an initializer (or initializers) to cover both these cases? Since your production database

Create fulltext index within Entity Framework Coded Migrations

青春壹個敷衍的年華 提交于 2019-11-30 01:24:18
问题 TLDR; How do you add a full text index using Entity framework 5 coded migrations I'm having issues adding a full text index to a database using Entity framework migrations. It needs to be there from the start so I'm attempting modifying the InitialCreate migration that was automatically generated to add it. As there isn't a way to do it via the DbMigrations API I've resorted to running inline sql at the end of the 'Up' code. Sql("create fulltext catalog AppNameCatalog;"); Sql("create fulltext

How to seed data using EntityFramework Code first Migrations

安稳与你 提交于 2019-11-30 01:20:49
问题 Hi I'm using the Beta 1 version of this nuGet package, the database is allready created and I need to know if there is a way to populate my tables through migrations. Thanxs 回答1: The intro post shows how to seed data http://blogs.msdn.com/b/adonet/archive/2011/11/29/code-first-migrations-beta-1-no-magic-walkthrough.aspx Seed data: Override the Seed method in this class to add seed data. - The Seed method will be called after migrating to the latest version. - You can use the DbContext

update-database error - NuGet Package (EntityFramework.SqlMigrations)

落爺英雄遲暮 提交于 2019-11-30 01:08:38
问题 i installed EntityFramework.SqlMigrations NuGet Package and i get this error . it worked for me in the past and somehow, now it does not work. PM> update-database The term 'update-database' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:16 + update-database <<<< + CategoryInfo : ObjectNotFound: (update-database:String) [],

What is the correct use of IDatabaseInitializer in EF?

邮差的信 提交于 2019-11-30 00:22:01
I have a custom DatabaseInitialiser which is below /// <summary> /// Implements the IDatabaseInitializer to provide a custom database initialisation for the context. /// </summary> /// <typeparam name="TContext">TContext is the DbContext</typeparam> public class ParikshaDataBaseInitializer<TContext> : IDatabaseInitializer<TContext> where TContext : DbContext { /// <summary> /// The method to Initialise the database. /// Takes care of the database cannot be dropped since it is in use problem while dropping and recreating the database. /// </summary> /// <param name="context">The DbContext on