Cosmos Hangs on OnModelCreating While Configuring Entity
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
## File a bug
I have configured several entities to work with a single Cosmos Container. Now I'm trying to configure another entity to work with a second container but ef core hand while trying to map to container. I've tested several cases and this seems to only happen while my entity owns other entities.
### Include your code
```C#
public abstract class AuditableEntity
{
public Guid Id {get; set; }
public DateTime Created { get; set; }
public string? CreatedBy { get; set; }
public DateTime? LastModified { get; set; }
public string? LastModifiedBy { get; set; }
}
public class Container1 : AuditableEntity
{
public string Container1Id {get; set; }
public string Name {get; set; }
}
public class Container2 : AuditableEntity
{
public string Container2Id {get; set; }
public string Name {get; set; }
}
public class CosmosContext : DbContext
{
public CosmosContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity().ToContainer("Container1")
.HasPartitionKey(i => i.Container1Id);
modelBuilder.Entity().Property(i => i.Id)
.HasConversion();
// Hangs here
modelBuilder.Entity().ToContainer("Container2")
.HasPartitionKey(i => i.Container2Id);
modelBuilder.Entity().Property(i => i.Id)
.HasConversion();
base.OnModelCreating(modelBuilder);
}
}
```
I've also tried adding owned entities to "Container2" but that causes the same issue
```c#
public class Foo
{
public string Bar {get; set;}
}
public class Container2
{
public string Container2Id {get; set; }
public string Name {get; set; }
public Foo Foo {get; set;}
}
```
### Include provider and version information
EF Core version:
Database provider: (e.g. Microsoft.EntityFrameworkCore.Cosmos)
Target framework: (e.g. .NET 7.0)
Operating system:
IDE: (e.g. Visual Studio for Mac Version 17.6.8 (build 400))
### Cosmos Configuration
Capacity mode: Provisioned throughput
Total throughput limit: 1600 RU/s
Both containers set to 400 RU/s (Default settings), both created using Microsoft.Azure.Cosmos.CosmosClient
Contributor guide
Assessment
This issue has not been assessed yet.