Reputation: 716
Im working with an ASP.NET boilerplate and would like to rename the sql tables it uses
I believe the relevant code is
public AlbumViewerContext(DbContextOptions options) : base(options)
{
}
public DbSet<Album> Albums { get; set; }
public DbSet<Artist> Artists { get; set; }
public DbSet<Track> Tracks { get; set; }
public DbSet<User> Users { get; set; }
It also includes models for Albums, Artists, Tracks and Users
How would i go about changing the SQL table names?
Upvotes: 0
Views: 49
Reputation: 1610
Add Table attribute on your Model. like as
[Table("Album")]
public class Album
{
public string Title { get; set; }
}
Upvotes: 1
Reputation: 65
.Net Core solution:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameTable(name: "OldTableName", schema: "dbo", newName: "NewTableName", newSchema: "dbo");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameTable(name: "NewTableName", schema: "dbo", newName: "OldTableName", newSchema: "dbo");
}
Upvotes: 0