I am having a difficulty when doing the automatic migration. Here is the case:
I have 2 contexts, one is EAccounting context and one is ECommerce context. EAccounting context has:
public DbSet<EA_Item> Items { get; set; }
And there is entity inside the ECommerce context which dependent to EA_Item
This is the entity in ECommerce that has EA_Item
dependency in it:
public DbSet<EC_Product> Products { get; set; }
And this is the EC_Product
:
[Table("EC_Product", Schema = "dbo")]
[Serializable]
public class EC_Product
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
[Display(Name = "Product Id")]
public int ProductId { get; set; }
[Display(Name = "Item Id")]
[Required]
public int ItemId { get; set; }
[Display(Name = "Published")]
public bool Published { get; set; }
[Display(Name = "Category")]
public int? CategoryId { get; set; }
[Display(Name = "Is Featured")]
public bool IsFeatured { get; set; }
[ForeignKey("ItemId")]
public virtual EAccounting.Models.EA_Item Item { get; set; }
[ForeignKey("CategoryId")]
public virtual ECommerce.Models.EC_Category Category { get; set; }
public EC_Product()
{
ItemId = 0;
CategoryId = null;
IsFeatured = false;
}
}
It has EA_Item
whenever I run the program it gives me:
entity framework migration There is already an object named "EA_Item" in the database.
EAccounting and ECommerce assemblies are not in one, they are seperated. EAccounting does not know there is ECommerce assembly, but ECommerce assembly requires EAccounting assembly to be loaded.
Is it possible to do this?