I'm trying to create a database model with Code First, without creating the database itself. That is, my DBA has set up an empty database, for which I have permission to create tables, but not a whole database. However, whenever I try to use Code First to set up the model, I get the following error:
CREATE DATABASE permission denied in database 'master'.
Is this just the way Code First works, or is there some way to modify the existing database?
P.S. -- here's the connection string --
<add name="HoursDb"
connectionString="Data Source=barksql.cedarville.edu;
Initial Catalog=Hours;
persist security info=True;
User ID=hours;
password=************;
multipleactiveresultsets=True;
App=EntityFramework"
providerName="System.Data.SqlClient" />
Update
Per @devdigital's request --
Here is the context class:
using System.Data.Entity;
using ....Models;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace LibraryAdmin.DAL
{
public class HoursDb : DbContext
{
public DbSet<DaySpec> DaySpecs { get; set; }
public DbSet<WeekSpec> WeekSpecs { get; set; }
public DbSet<ExceptionHoursSet> ExceptionHoursSets { get; set; }
public DbSet<Schedule> Schedules { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
}
As far as mapping the database to the connection, I am assuming it is done by a convention since the HoursDb classname matches the connection string name.