Reputation: 1039
I followed a tutorial on pluralsight for ASP .NET 5 and EF 7 using Code First DB. This is the connection string :
"WorldContextConnection": "Server=CVU-OCTAVIANE\\SQLEXPRESS;Database=TheWorldDB;Trusted_Connection=true;"
I added the initial migration (which worked fine) and then I tried to use a EF 7 feature to create the DB automatically: I created a Context type class where I used Database.EnsureCreated() to create the DB on the first run. This is the context class:
public class WorldContext : DbContext
{
public WorldContext()
{
Database.EnsureCreated();
}
public DbSet<Trip> Trips { get; set; }
public DbSet<Stop> Stops { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var connString = Startup.Configuration["Data:WorldContextConnection"];
optionsBuilder.UseSqlServer(connString);
base.OnConfiguring(optionsBuilder);
}
}
When I ran the project "A severe error occurred on the current command"
Thanks
Upvotes: 1
Views: 315
Reputation: 527
Actually I had the same problem of yours, and I took a few steps less.
Upvotes: 0
Reputation: 410
I had the same problem and seem to have resolved it.
I'm not sure if all of the below is required, but are the steps I took
Upvotes: 1