Generated migration derived class uses enum with no using directive
version="7.0.0-beta4-12265" targetFramework="net451
Add-Migration creates migration derived class using enum from Domain Models but has no using directive, hence code cannot compile.
Error is: The type or namespace name 'AnimalGroup' could not be found (are you missing a using directive or an assembly reference?) c:\projects\2013\SightingsWebApp\SightingsWebApp\Migrations\20150216133708_InitialCreate.Designer.cs 32 36 SightingsWebApp
Domain Model:
public class ZooAnimalSighting
{
public int ZooAnimalSightingId { get; set; }
public string Sighter { get; set; }
public DateTime DateOf { get; set; }
public bool IsSightingReliable { get; set; }
public virtual Animal Animal { get; set; }
}
public class Zoo
{
public int ZooId { get; set; }
public string Name { get; set; }
public string City { get; set; }
public virtual ICollection<Animal> Animals { get; set; }
}
public class Animal
{
public int AnimalId { get; set; }
public string Name { get; set; }
public float Weight { get; set; }
public AnimalGroup? Group { get; set; }
public virtual Zoo Zoo { get; set; }
}
public enum AnimalGroup
{
Invertebrate,
Fish,
Amphibian,
Reptile,
Mammal,
Bird
}
We shouldn't use the enum type name because the user may remove it from their project at a later date and the old migrations still need to compile.
We are handling enum type properly but in this case nullable enum is being used which is not handled properly. Should I fix this separately or take it as a part of #1484 ?
@smitpatel You can just address it (and any other bugs in the model snapshot code) as part of #1484