{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3751","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3751/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3751/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3751/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3751","id":116849614,"number":3751,"title":"Add migrations drop and create foregin key on table that not is modified","user":{"login":"Tasteful","id":357589,"avatar_url":"https://avatars.githubusercontent.com/u/357589?v=3","gravatar_id":"","url":"https://api.github.com/users/Tasteful","html_url":"https://github.com/Tasteful","followers_url":"https://api.github.com/users/Tasteful/followers","following_url":"https://api.github.com/users/Tasteful/following{/other_user}","gists_url":"https://api.github.com/users/Tasteful/gists{/gist_id}","starred_url":"https://api.github.com/users/Tasteful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tasteful/subscriptions","organizations_url":"https://api.github.com/users/Tasteful/orgs","repos_url":"https://api.github.com/users/Tasteful/repos","events_url":"https://api.github.com/users/Tasteful/events{/privacy}","received_events_url":"https://api.github.com/users/Tasteful/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-13T20:51:57Z","updated_at":"2015-11-13T21:04:19Z","closed_at":null,"body":"When adding a new migraion a lot of ```DropForeginKey``` and ´´´AddForeginKey``` are added even if the table not is touched by the rest of the migration commands. See example the ```CategoryFieldData``` table in the below migration.\r\n\r\nIs there any reason for this approach?\r\n\r\nUsing beta8-version.\r\n```\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing Microsoft.Data.Entity.Migrations;\r\n\r\nnamespace Application.Migrations\r\n{\r\n    public partial class WorkflowFieldFramework : Migration\r\n    {\r\n        protected override void Up(MigrationBuilder migrationBuilder)\r\n        {\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_AssortmentFieldData_Assortment_OwnerId\", schema: \"Products\", table: \"AssortmentFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_CategoryFieldData_Category_OwnerId\", schema: \"Products\", table: \"CategoryFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_FieldDefinitionFieldData_FieldDefinition_OwnerId\", schema: \"Products\", table: \"FieldDefinitionFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_FieldTemplateFieldData_FieldTemplate_OwnerId\", schema: \"Products\", table: \"FieldTemplateFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_ProductFieldData_Product_OwnerId\", schema: \"Products\", table: \"ProductFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_VariantFieldData_Variant_OwnerId\", schema: \"Products\", table: \"VariantFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_WorkflowTaskConditionEntity_WorkflowTaskEntity_WorkflowTaskId\", schema: \"Products\", table: \"WorkflowTaskCondition\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_WorkflowTaskEntity_WorkflowEntity_WorkflowId\", schema: \"Products\", table: \"WorkflowTask\");\r\n            migrationBuilder.DropTable(name: \"WorkflowLocalization\", schema: \"Products\");\r\n            migrationBuilder.DropTable(name: \"WorkflowTaskLocalization\", schema: \"Products\");\r\n            migrationBuilder.CreateTable(\r\n                name: \"WorkflowFieldData\",\r\n                schema: \"Products\",\r\n                columns: table => new\r\n                {\r\n                    OwnerId = table.Column<Guid>(nullable: false),\r\n                    Id = table.Column<string>(nullable: false),\r\n                    Culture = table.Column<string>(nullable: false),\r\n                    BooleanValue = table.Column<bool>(nullable: true),\r\n                    DateTimeValue = table.Column<DateTime>(nullable: true),\r\n                    DecimalValue = table.Column<decimal>(nullable: true),\r\n                    GuidValue = table.Column<Guid>(nullable: true),\r\n                    IndexedTextValue = table.Column<string>(nullable: true),\r\n                    IntValue = table.Column<long>(nullable: true),\r\n                    JsonData = table.Column<string>(nullable: true),\r\n                    TextValue = table.Column<string>(nullable: true)\r\n                },\r\n                constraints: table =>\r\n                {\r\n                    table.PrimaryKey(\"PK_Products_WorkflowFieldData\", x => new { x.OwnerId, x.Id, x.Culture });\r\n                    table.ForeignKey(\r\n                        name: \"FK_Products_WorkflowFieldData_Workflow_OwnerId\",\r\n                        column: x => x.OwnerId,\r\n                        principalSchema: \"Products\",\r\n                        principalTable: \"Workflow\",\r\n                        principalColumn: \"Id\",\r\n                        onDelete: ReferentialAction.Cascade);\r\n                });\r\n            migrationBuilder.CreateTable(\r\n                name: \"WorkflowTaskFieldData\",\r\n                schema: \"Products\",\r\n                columns: table => new\r\n                {\r\n                    OwnerId = table.Column<Guid>(nullable: false),\r\n                    Id = table.Column<string>(nullable: false),\r\n                    Culture = table.Column<string>(nullable: false),\r\n                    BooleanValue = table.Column<bool>(nullable: true),\r\n                    DateTimeValue = table.Column<DateTime>(nullable: true),\r\n                    DecimalValue = table.Column<decimal>(nullable: true),\r\n                    GuidValue = table.Column<Guid>(nullable: true),\r\n                    IndexedTextValue = table.Column<string>(nullable: true),\r\n                    IntValue = table.Column<long>(nullable: true),\r\n                    JsonData = table.Column<string>(nullable: true),\r\n                    TextValue = table.Column<string>(nullable: true)\r\n                },\r\n                constraints: table =>\r\n                {\r\n                    table.PrimaryKey(\"PK_Products_WorkflowTaskFieldData\", x => new { x.OwnerId, x.Id, x.Culture });\r\n                    table.ForeignKey(\r\n                        name: \"FK_Products_WorkflowTaskFieldData_WorkflowTask_OwnerId\",\r\n                        column: x => x.OwnerId,\r\n                        principalSchema: \"Products\",\r\n                        principalTable: \"WorkflowTask\",\r\n                        principalColumn: \"Id\",\r\n                        onDelete: ReferentialAction.Cascade);\r\n                });\r\n            migrationBuilder.CreateIndex(\r\n                name: \"IX_Products_WorkflowFieldData_IndexedTextValue\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowFieldData\",\r\n                column: \"IndexedTextValue\");\r\n            migrationBuilder.CreateIndex(\r\n                name: \"IX_Products_WorkflowFieldData_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowFieldData\",\r\n                column: \"OwnerId\");\r\n            migrationBuilder.CreateIndex(\r\n                name: \"IX_Products_WorkflowTaskFieldData_IndexedTextValue\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTaskFieldData\",\r\n                column: \"IndexedTextValue\");\r\n            migrationBuilder.CreateIndex(\r\n                name: \"IX_Products_WorkflowTaskFieldData_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTaskFieldData\",\r\n                column: \"OwnerId\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_AssortmentFieldData_Assortment_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"AssortmentFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Assortment\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_CategoryFieldData_Category_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"CategoryFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Category\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_FieldDefinitionFieldData_FieldDefinition_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"FieldDefinitionFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"FieldDefinition\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_FieldTemplateFieldData_FieldTemplate_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"FieldTemplateFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"FieldTemplate\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_ProductFieldData_Product_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"ProductFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Product\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_VariantFieldData_Variant_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"VariantFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Variant\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_WorkflowTaskConditionEntity_WorkflowTaskEntity_WorkflowTaskId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTaskCondition\",\r\n                column: \"WorkflowTaskId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"WorkflowTask\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_WorkflowTaskEntity_WorkflowEntity_WorkflowId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTask\",\r\n                column: \"WorkflowId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Workflow\",\r\n                principalColumn: \"Id\",\r\n                onDelete: ReferentialAction.Cascade);\r\n        }\r\n\r\n        protected override void Down(MigrationBuilder migrationBuilder)\r\n        {\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_AssortmentFieldData_Assortment_OwnerId\", schema: \"Products\", table: \"AssortmentFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_CategoryFieldData_Category_OwnerId\", schema: \"Products\", table: \"CategoryFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_FieldDefinitionFieldData_FieldDefinition_OwnerId\", schema: \"Products\", table: \"FieldDefinitionFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_FieldTemplateFieldData_FieldTemplate_OwnerId\", schema: \"Products\", table: \"FieldTemplateFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_ProductFieldData_Product_OwnerId\", schema: \"Products\", table: \"ProductFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_Products_VariantFieldData_Variant_OwnerId\", schema: \"Products\", table: \"VariantFieldData\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_WorkflowTaskConditionEntity_WorkflowTaskEntity_WorkflowTaskId\", schema: \"Products\", table: \"WorkflowTaskCondition\");\r\n            migrationBuilder.DropForeignKey(name: \"FK_WorkflowTaskEntity_WorkflowEntity_WorkflowId\", schema: \"Products\", table: \"WorkflowTask\");\r\n            migrationBuilder.DropTable(name: \"WorkflowFieldData\", schema: \"Products\");\r\n            migrationBuilder.DropTable(name: \"WorkflowTaskFieldData\", schema: \"Products\");\r\n            migrationBuilder.CreateTable(\r\n                name: \"WorkflowLocalization\",\r\n                schema: \"Products\",\r\n                columns: table => new\r\n                {\r\n                    Culture = table.Column<string>(nullable: false),\r\n                    WorkflowId = table.Column<Guid>(nullable: false),\r\n                    Name = table.Column<string>(nullable: true)\r\n                },\r\n                constraints: table =>\r\n                {\r\n                    table.PrimaryKey(\"PK_WorkflowLocalizationEntity\", x => new { x.Culture, x.WorkflowId });\r\n                    table.ForeignKey(\r\n                        name: \"FK_WorkflowLocalizationEntity_WorkflowEntity_WorkflowId\",\r\n                        column: x => x.WorkflowId,\r\n                        principalSchema: \"Products\",\r\n                        principalTable: \"Workflow\",\r\n                        principalColumn: \"Id\");\r\n                });\r\n            migrationBuilder.CreateTable(\r\n                name: \"WorkflowTaskLocalization\",\r\n                schema: \"Products\",\r\n                columns: table => new\r\n                {\r\n                    Culture = table.Column<string>(nullable: false),\r\n                    WorkflowTaskId = table.Column<Guid>(nullable: false),\r\n                    Name = table.Column<string>(nullable: true)\r\n                },\r\n                constraints: table =>\r\n                {\r\n                    table.PrimaryKey(\"PK_WorkflowTaskLocalizationEntity\", x => new { x.Culture, x.WorkflowTaskId });\r\n                    table.ForeignKey(\r\n                        name: \"FK_WorkflowTaskLocalizationEntity_WorkflowTaskEntity_WorkflowTaskId\",\r\n                        column: x => x.WorkflowTaskId,\r\n                        principalSchema: \"Products\",\r\n                        principalTable: \"WorkflowTask\",\r\n                        principalColumn: \"Id\");\r\n                });\r\n            migrationBuilder.CreateIndex(\r\n                name: \"IX_WorkflowLocalizationEntity_WorkflowId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowLocalization\",\r\n                column: \"WorkflowId\");\r\n            migrationBuilder.CreateIndex(\r\n                name: \"IX_WorkflowTaskLocalizationEntity_WorkflowTaskId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTaskLocalization\",\r\n                column: \"WorkflowTaskId\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_AssortmentFieldData_Assortment_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"AssortmentFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Assortment\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_CategoryFieldData_Category_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"CategoryFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Category\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_FieldDefinitionFieldData_FieldDefinition_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"FieldDefinitionFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"FieldDefinition\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_FieldTemplateFieldData_FieldTemplate_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"FieldTemplateFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"FieldTemplate\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_ProductFieldData_Product_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"ProductFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Product\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_Products_VariantFieldData_Variant_OwnerId\",\r\n                schema: \"Products\",\r\n                table: \"VariantFieldData\",\r\n                column: \"OwnerId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Variant\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_WorkflowTaskConditionEntity_WorkflowTaskEntity_WorkflowTaskId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTaskCondition\",\r\n                column: \"WorkflowTaskId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"WorkflowTask\",\r\n                principalColumn: \"Id\");\r\n            migrationBuilder.AddForeignKey(\r\n                name: \"FK_WorkflowTaskEntity_WorkflowEntity_WorkflowId\",\r\n                schema: \"Products\",\r\n                table: \"WorkflowTask\",\r\n                column: \"WorkflowId\",\r\n                principalSchema: \"Products\",\r\n                principalTable: \"Workflow\",\r\n                principalColumn: \"Id\");\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/156555948","html_url":"https://github.com/aspnet/EntityFramework/issues/3751#issuecomment-156555948","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3751","id":156555948,"user":{"login":"Tasteful","id":357589,"avatar_url":"https://avatars.githubusercontent.com/u/357589?v=3","gravatar_id":"","url":"https://api.github.com/users/Tasteful","html_url":"https://github.com/Tasteful","followers_url":"https://api.github.com/users/Tasteful/followers","following_url":"https://api.github.com/users/Tasteful/following{/other_user}","gists_url":"https://api.github.com/users/Tasteful/gists{/gist_id}","starred_url":"https://api.github.com/users/Tasteful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tasteful/subscriptions","organizations_url":"https://api.github.com/users/Tasteful/orgs","repos_url":"https://api.github.com/users/Tasteful/repos","events_url":"https://api.github.com/users/Tasteful/events{/privacy}","received_events_url":"https://api.github.com/users/Tasteful/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T21:04:19Z","updated_at":"2015-11-13T21:04:19Z","body":"Maybe I can answer it this by myself :) I was adding a navigation property on the base-class for the entities that have tables that ends with \"FieldData\". But that navigation property was anyway not modifying the database schema."}}