Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Created Unassigned: EF is asking for views it did not create [1531]

$
0
0
If relationships exist in the model runtime asks for views it did not create. This gets even more complicated because the number of created views depends on whether this is an independent association or an FK (for 1 - * in case of independent association 5 views are created while only 4 views will be created for FK).

The model (comment out the PrincipalId property to get an IA)
```
public class MyEntity
{
public int Id { get; set; }
public string Name { get; set; }

public int PrincipalId { get; set; }

public Principal Parent { get; set; }
}

public class Principal
{
public int Id { get; set; }
public string Name { get; set; }

public ICollection<MyEntity> Entities { get; set; }
}

public class MyContext : DbContext
{
public DbSet<MyEntity> Entities { get; set; }
}
```

Views created for FK:

CodeFirstDatabase.MyEntity
CodeFirstDatabase.Principal
MyContext.Entities
MyContext.Principals

Views created for IA:

CodeFirstDatabase.MyEntity
CodeFirstDatabase.Principal
MyContext.Entities
MyContext.Principal_Entities
MyContext.Principals

Views EF is asking for (in both cases):
CodeFirstDatabase.MyEntity
CodeFirstDatabase.Principal
CodeFirstDatabase.Principal_Entities
MyContext.Entities
MyContext.Principal_Entities
MyContext.Principals

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>