Richard77
Richard77

Reputation: 21621

Code first is keep creating a database with the fully qualified name of my context

This is my context class

public class HospitalContext : DbContext 
{
    public DbSet<Patient> Patients { get; set; }
    public DbSet<Doctor> Doctors { get; set; }
    public DbSet<Appointment> Appointments { get; set; }
    public DbSet<Schedule> Schedule { get; set; }
}

And my connection string

<add name="DbContext" 
     providerName="System.Data.SqlClient" 
     connectionString="Data Source=(LocalDb)\v11.0;
     Initial Catalog=HospitalProject;
     Integrated Security=True;" />

I'd like to know why when I run the application, the database name is

HospitalProject.Models.HospitalContext

instead of HospitalProject.

Thanks for helping

Upvotes: 0

Views: 137

Answers (1)

Jayantha Lal Sirisena
Jayantha Lal Sirisena

Reputation: 21366

Try renaming connection string to HospitalContext instead of DbContext

Upvotes: 1

Related Questions