I have an existing database already that was created when i added Identity to the project. Now i wanna add more tables to the database and can't figure out how.
I have created a model for it:
public class Match
{
public Guid ID { get; set; }
public string HomeTeam { get; set; }
public string AwayTeam { get; set; }
public int FullTimeScore { get; set; }
public DateTime MatchStart { get; set; }
public int PrizePool { get; set; }
}
My context:
public class DynamicBettingUserContext : IdentityDbContext<IdentityUser>
{
public DynamicBettingUserContext(DbContextOptions<DynamicBettingUserContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
What's the next steps?
You need to add the Match
table in your DynamicBettingUserContext
class like below. Then You need to add migration using Add-Migration <YourMigrationName>
in Package Manager Console and finally, You have to run Update-Database
command in PMC.
public virtual DbSet<Match> Match { get; set; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With