AspNetMVC-InventoryManagement-WebApi
AspNetMVC-InventoryManagement-WebApi copied to clipboard
Database script missing
Hi falaybeg
thanks for your contribution. i was trying to get that project running in my vs.net 2019 ide. i changed the InventoryDbContext in web.config to point to my sql server. maybe i'm missing something but i believe the SQL database script is not provided in the source? or is it a code-first solution where i can generate the database somehow?
thanks and kind regards
Christian
Hi itsChris could you please share the database script, code first approach is not working on my ends
Hello,
Delete all migrations from migrations folder.
Then run the following commands in package-manager console.
Enable-Migrations -Force
Add-Migration init
Update-Database
İf you want initial users also replace seed function at configuration class with this :
protected override void Seed(NtierApp.Repository.Context.InventoryDbContext context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data.
if (!(context.Users.Any(u => u.UserName == "[email protected]")))
{
var userStore = new UserStore<ApplicationUserr>(context);
var userManager = new UserManager<ApplicationUserr>(userStore);
var userToInsert = new ApplicationUserr { UserName = "[email protected]", PhoneNumber = "123123", Email = "[email protected]", RegisteredDate = DateTime.Now };
userManager.Create(userToInsert, "Password@123");
}
}