79435714

Date: 2025-02-13 09:50:17
Score: 1
Natty:
Report link

You can try to add this

.ApplyAllDatabaseChangesOnStartup();

at the end of the AddMarten method. E.i:

// Marten configuration
builder.Services.AddMarten(options =>
{
    var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
    options.Connection(connectionString);
    options.AutoCreateSchemaObjects = AutoCreate.All;

    // Document mappings
    options.Schema.For<Baum>().Identity(x => x.Id);
    options.Schema.For<Auftrag>().Identity(x => x.Id);
    options.Schema.For<Baumart>().Identity(x => x.Id);
    options.Schema.For<Gehölzdaten>().Identity(x => x.Id);
    options.Schema.For<Koordinatentyp>(); 
    options.Schema.For<Baumkontrolle>().ForeignKey<Auftrag>(x => x.AuftragId);
    options.Schema.For<Baumpflege>().ForeignKey<Auftrag>(x => x.AuftragId);
})
.ApplyAllDatabaseChangesOnStartup();

References: https://martendb.io/schema/migrations.html#apply-all-outstanding-changes-upfront https://martendb.io/schema/#overriding-schema-name

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: codingman123