In my ASP.NET Core 1.0, MVC6, EF7 web application, I'm adding a migration that adds a new related table (& corresponding model). I have the following model snapshot:
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "7.0.0-rc1-16348")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Salesboost.Models.ApplicationUser", b =>
{
b.Property<string>("Id");
b.Property<int?>("TeamId");
b.HasKey("Id");
// -- <unrelated fields snipped> --
});
// -- <snipped> --
modelBuilder.Entity("Team", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name").IsRequired();
b.Property<string>("ManagerId").IsRequired();
b.HasKey("Id");
});
modelBuilder.Entity("Team", b =>
{
b.HasOne("ApplicationUser", "Manager")
.WithOne("TeamManaging")
.HasForeignKey("ManagerId");
});
}
}
Team.cs:
public class Team
{
public int Id { get; set; }
public string Name { get; set; }
public string ManagerId { get; set; }
public virtual ApplicationUser Manager { get; set; }
public virtual ICollection<ApplicationUser> Members { get; set; }
}
ApplicationUser:
public class ApplicationUser : Microsoft.AspNet.Identity.EntityFramework.IdentityUser
{
public int? TeamId { get; set; }
public virtual Team Team { get; set; }
public virtual Team TeamManaging { get; set; }
}
When I attempt to update the database, dnx gives me the following error:
The navigation property 'Manager' cannot be added to the entity type 'Team' because the entity type is defined in shadow state and navigations properties cannot be added to shadow state.
What does it mean for an entity type to be in "shadow state"? Is there a way around this?
ApplicationUser
? – Kelcie