I've created an ASP.NET MVC sample application in Visual Studio. I added two classes like below :
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public int Price { get; set; }
public ICollection<Product> Products { get; set; }
}
public class Order
{
public int Id{ get; set; }
public Product Product { get; set; }
public int ProductId { get; set; }
public DateTime RegisterDate { get; set; }
}
and then I added two DbSet to the main DbContext like this:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public IDbSet<Product> Products { get; set; }
public IDbSet<Order> Orders { get; set; }
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
But now when I run project, I get this error :
The model backing the 'ApplicationDbContext' context has changed since the database was created
I just wanted to know is there a way to update the database without using migrations (Add-migrations and update-database)?
dbo.__MigrationHistoryand try. Please see my answer below stackoverflow.com/a/67821254/3057246