Как исправить «Ошибка экземпляра».вверх «Обновление базы данных» - PullRequest
0 голосов
/ 19 февраля 2019

Я настраиваю очень базовый контекст базы данных подхода для моего приложения.У меня есть проекты MVC (UI) и библиотеки классов (EntityFramework) под моим решением.При Update-Database получая ошибку Instance failure.

// Конфигурация миграции

internal sealed class Configuration : DbMigrationsConfiguration<UrfPractice.EntityFramework.UrfPracticeDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
    }
}

// Контекст базы данных

public class UrfPracticeDbContext : DbContext
{
    static UrfPracticeDbContext()
    {
        Database.SetInitializer<UrfPracticeDbContext>(null);
    }
    public UrfPracticeDbContext() : base("name=DefaultConnectionString")
    {
    Configuration.AutoDetectChangesEnabled = true;
    Configuration.LazyLoadingEnabled = true;
    Configuration.ProxyCreationEnabled = false;
    }
    public DbSet<Entities.Customer> Customers { get; set; }
}

// Миграция клиента

public partial class Customer : DbMigration
{
    public override void Up()
    {
        CreateTable(
        "dbo.tblCustomers",
        c => new {
            Id = c.Int(nullable: false, identity: true),
            CustomerId = c.Int(nullable: false),
            Fullname = c.String(nullable: false, maxLength: 256)
        }).PrimaryKey(t => t.Id);
    }
    public override void Down()
    { DropTable("dbo.tblCustomers"); }
}

// Класс сущности

[Table("tblCustomers")] public class Customer {
    [Key]
    public int CustomerId { get; set; }
    [MaxLength(250)]
    public string Fullname { get; set; }
}

Снимок экрана => https://user -images.githubusercontent.com / 47334134/53000129-b4582800-3438-11e9-9d17-4f1903c5d623.png enter image description here

...