CSharp · Console
using Microsoft.EntityFrameworkCore;
using var cxt = new CosmosDbCxt();
cxt.Find<EntityType1>(); // trigger building of the dbcontext
public class CosmosDbCxt : DbContext
{
public DbSet<EntityType1> EntityType1 { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseCosmos( // you can stick with the fake values, the exception will be thrown prior to the connection
"<edpt>",
"<key>",
"<dbName>");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<EntityType1>().Ignore(x => x.E2); // exception thrown here
throw new System.Exception("Expected Stop");
}
}
public class EntityType1
{
public EntityType2 E2 { get; set; }
}
public class EntityType2
{
public EntityType3 E3 { get; set; }
public EntityType4 E4 { get; set; }
}
public class EntityType3
{
public EntityType2 U2 { get; set; } // changing the property name here will either fix or break the issue, name like 'E2', 'A' is fine, but name like 'U2', 'Exy' is not. I could not find a pattern here
}
public class EntityType4
{
public EntityType3? E3 { get; set; }
}