database - EntityFramework5 Code-First Migration -
i running entityframework5 code-first , enabled migration package manager console. after enabled migration configuration.cs file added migrations folder, not initialcreate.cs.
i change 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 fix it?
note:
1.i new in migration database.
2.business objects files , dbcontext class different class libraries.
add initial migration manually using add-migration "initial"
in package manager console. if still doesn't create migration file, manually delete database , migrations folder , enable-migrations
followed add-migration "initial"
should work.
Comments
Post a Comment