I am running EntityFramework5 with Code-First and Enabled Migration with package manager console. After enabled migration only Configuration.cs file was added to Migrations folder, not InitialCreate.cs.
I change my class from
public class Product
{
public Product()
{
this.CreationDate = DateTime.Now;
}
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid ProductId { get; set; }
public DateTime CreationDate { get; set; }
public string Image { get; set; }
public string ImageThubmnail { get; set; }
[ForeignKey("Category")]
public Guid CategoryId { get; set; }
public virtual Category Category { get; set; }
[ForeignKey("Company")]
public Guid CompanyId { get; set; }
public virtual Company Company { get; set; }
}
to
public class Product
{
public Product()
{
this.CreationDate = DateTime.Now;
}
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid ProductId { get; set; }
public DateTime CreationDate { get; set; }
public string Name { get; set; }
public string Image { get; set; }
public string ImageThubmnail { get; set; }
[ForeignKey("Category")]
public Guid CategoryId { get; set; }
public virtual Category Category { get; set; }
[ForeignKey("Company")]
public Guid CompanyId { get; set; }
public virtual Company Company { get; set; }
}
How can I fix it?
Note:
1.I am new in migration database.
2.Business Objects files and DbContext class are different class libraries.