public class Cae
{
public long Id { get; set; }
[Required]
public long Empresa_Id { get; set; }
public virtual Empresa Empresa { get; set; }
[Required]
public int CAETipoCFE { get; set; }
[Required]
[Index(IsUnique = true)]
public long CAENumero { get; set; }
[Required]
public long CAENumInicial { get; set; }
[Required]
public long CAENumFinal { get; set; }
[Required]
public DateTime CAEFechaVencimiento { get; set; }
public int? CAEEspecial { get; set; }
public int? CAECausalTipoDelCae { get; set; }
public bool CAEFinalizado { get; set; }
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Cae>().HasIndex(c => c.Empresa_Id);
}
public partial class AddIndexEmpresaID : DbMigration
{
public override void Up()
{
DropForeignKey("dbo.Caes", "Empresa_Id", "dbo.Empresas");
DropIndex("dbo.Caes", new[] { "Empresa_Id" });
AddColumn("dbo.Caes", "Empresa_Id1", c => c.Long());
CreateIndex("dbo.Caes", "Empresa_Id");
CreateIndex("dbo.Caes", "Empresa_Id1");
AddForeignKey("dbo.Caes", "Empresa_Id1", "dbo.Empresas", "Id");
}
public override void Down()
{
DropForeignKey("dbo.Caes", "Empresa_Id1", "dbo.Empresas");
DropIndex("dbo.Caes", new[] { "Empresa_Id1" });
DropIndex("dbo.Caes", new[] { "Empresa_Id" });
DropColumn("dbo.Caes", "Empresa_Id1");
CreateIndex("dbo.Caes", "Empresa_Id");
AddForeignKey("dbo.Caes", "Empresa_Id", "dbo.Empresas", "Id", cascadeDelete: true);
}
}
}