1 | initial version |
To indicate the name of a database using Code First, you can use the DbContext
class and override the OnModelCreating
method. Within this method, you can use the modelBuilder
parameter to specify the name of the database by calling the HasDatabaseName
method.
Example:
public class MyDbContext : DbContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDatabaseName("MyDatabaseName");
}
}
This will set the name of your database to "MyDatabaseName".