ef-migrations

Entity Framework 6 - Does not create tables when enabling Migrations

拟墨画扇 提交于 2019-11-30 20:30:39
In my application I enable Code First Migrations with some migrations, Also I use SQL Server Compact for integration test. When I run my tests, Entity Framework create an empty database and tries to run migration on that empty database and thrown The specified table does not exist. Based on this report I think usage of Migration in Entity Framework 6 has changed. I test all Database Initializer with Context.Database.Create(); but in all case tabale's never created. I don't know that this is EntityFramework's bug or not, but when I made rename the namespace of Migration Configuration class from

Is there a way to make EF 5 code first migrations use a sql server database in ASP.NET MVC 4 for everything?

浪子不回头ぞ 提交于 2019-11-30 19:24:31
问题 I would like for it to use SQL Server by default for everything when I start a new ASP.NET MVC 4 Web Application project. By default when you run this project it creates a LocalDb instance and creates the following tables in it: webpages_Membership webpages_OAuthMembership webpages_Roles webpages_UsersInRoles UserProfile I have been able to use a code first migration to put the UserProfile table into a SQL server database. However, I have not been able to accomplish this with the other 4

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

£可爱£侵袭症+ 提交于 2019-11-30 17:58:44
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) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Occurs with EF5 RTM, VS2012 RTM . I

Code First Migrations - Update-database -script command generated SQL script not working

点点圈 提交于 2019-11-30 17:51:42
问题 I have to created a database through Entity Framework 5 with the following model: public class Post { public int PostId { get; set; } [MaxLength(200)] public string Title { get; set; } public string Content { get; set; } public int BlogId { get; set; } public Blog Blog { get; set; } } Then I have added new property in Post public string Abstract { get; set; } then I have run Add-Migration AddPostAbstract which created the following class in my Migrations folder, after that I have modified

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

拜拜、爱过 提交于 2019-11-30 17:46:02
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), }) .PrimaryKey(t => t.Email); } public override void Down() { DropTable("gligoran.Subscribers"); } } I'd like

Entity Framework Data Annotations equivalent of .WillCascadeOnDelete(false);

 ̄綄美尐妖づ 提交于 2019-11-30 17:40:26
I'm currently using EF Code First 4.3 with migrations enabled, but automatic migrations disabled. My question is simple, is there a data annotations equivalent of the model configuration .WillCascadeOnDelete(false) I would like to decorate my class so that the foreign key relationships do NOT trigger a cascading delete. Code sample: public class Container { public int ContainerID { get; set; } public string Name { get; set; } public virtual ICollection<Output> Outputs { get; set; } } public class Output { public int ContainerID { get; set; } public virtual Container Container { get; set; }

Create fulltext index within Entity Framework Coded Migrations

依然范特西╮ 提交于 2019-11-30 17:37:41
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 index on Document (Data type column Extension) key index [PK_dbo.Document] on AppNameCatalog;"); When

Entity Framework Migrations can't drop table because of foreign key constraint

会有一股神秘感。 提交于 2019-11-30 17:25:11
I have reverse-engineered the existing database to the code-first model. Some tables are to be kept but most are to be removed and completely re-architected for the new version. I delete some old classes and their mapping and add-migration. The migration looks like this: public override void Up() { DropForeignKey("dbo.Bingo_Review", "BingoID", "dbo.Bingo"); DropForeignKey("dbo.Bingo_Review_Text", "BingoReviewID", "dbo.Bingo_Review"); DropForeignKey("dbo.Bingo_Bonus", "BingoID", "dbo.Bingo"); DropForeignKey("dbo.Bingo_Bonus_Amount", "BingoBonusID", "dbo.Bingo_Bonus"); DropIndex("dbo.Bingo_Bonus

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

喜你入骨 提交于 2019-11-30 17:17:42
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 multiple constraints across multiple migration files, the script generated by EF tends to re-declare

Add an implementation of 'IDesignTimeDbContextFactory<ServicesDbContext>' to the project error while creating a migration step in .NET core 2.0

柔情痞子 提交于 2019-11-30 17:17:37
问题 I had a .NET core 1.0 webapp working fine. I had to upgrade to .NET Core 2.0. I also had to add a migration step for my SQLite database. If I launch this command: Add-Migration MyMigrationStepName I get this error: Unable to create an object of type 'ServicesDbContext'. Add an implementation of 'IDesignTimeDbContextFactory' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. I've seen plenty of answers on SO and on other