Pankaj Sharma

Pankaj Sharma

  • NA
  • 40
  • 3.3k

Migration Exception Unhandled in Entity Framework

May 14 2016 12:45 PM
I am working of Entity Framework code First approach i am new to Entity Framework..
Today i was working of configure entity mapping using the Fluent API. I was trying to change the schema of database using below code ..
 Code of My Employee_Context class is
 
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity2
{
class EmployeeContext:DbContext
{
public EmployeeContext() : base("name=Emp_Connect")
{
Database.SetInitializer(new MigrateDatabaseToLatestVersion<EmployeeContext, Entity2.Migrations.Configuration>("Emp_Connect"));
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//Configure Domain Classes Here
modelBuilder.HasDefaultSchema("Admin");
}
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<Project> Projects { get; set; }
}
}
 
 
When i run the program then i got following error..
 
 Automatic migrations that affect the location of the migrations history system table (such as default schema changes) are not supported. Please use code-based migrations for operations that affect the location of the migrations history system table.
 
 
I don't know how to solve this   Please help me.... 

Answers (1)