Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenAb 1.10: Meldepflicht für IT-Vorfälle in Österreich | heise online(22.09.2026 um 23:31 Uhr)
IT Security NachrichtenIT Security News Daily Summary 2026-09-22(22.09.2026 um 23:55 Uhr)
IT Security NachrichtenIT Security News Hourly Summary 2026-09-23 00h : 3 posts(23.09.2026 um 00:00 Uhr)
IT Security NachrichtenRelays Are Masking Chinese Access to Frontier AI Models in the US(22.09.2026 um 23:12 Uhr)
Malware / Trojaner / VirenAttackers Use Wallpaper Engine to Distribute Malware(22.09.2026 um 15:10 Uhr)
IT Security NachrichtenSweden fines Miljödata $183,000 over breach affecting 2.2 million(22.09.2026 um 23:40 Uhr)
IT Security NachrichtenRogue external MFA providers can steal passwords during logins(22.09.2026 um 23:45 Uhr)
IT Security NachrichtenÖsterreich setzt NIS2 um, erhält Bundesamt für Cybersicherheit(22.09.2026 um 23:24 Uhr)
IT NachrichtenHere’s a Newer Galaxy Z Fold 8 Update for You(22.09.2026 um 23:19 Uhr)
IT Security NachrichtenAb 1.10: Meldepflicht für IT-Vorfälle in Österreich | heise online(22.09.2026 um 23:31 Uhr)
IT Security NachrichtenIT Security News Daily Summary 2026-09-22(22.09.2026 um 23:55 Uhr)
IT Security NachrichtenIT Security News Hourly Summary 2026-09-23 00h : 3 posts(23.09.2026 um 00:00 Uhr)
IT Security NachrichtenRelays Are Masking Chinese Access to Frontier AI Models in the US(22.09.2026 um 23:12 Uhr)
Malware / Trojaner / VirenAttackers Use Wallpaper Engine to Distribute Malware(22.09.2026 um 15:10 Uhr)
IT Security NachrichtenSweden fines Miljödata $183,000 over breach affecting 2.2 million(22.09.2026 um 23:40 Uhr)
IT Security NachrichtenRogue external MFA providers can steal passwords during logins(22.09.2026 um 23:45 Uhr)
IT Security NachrichtenÖsterreich setzt NIS2 um, erhält Bundesamt für Cybersicherheit(22.09.2026 um 23:24 Uhr)
IT NachrichtenHere’s a Newer Galaxy Z Fold 8 Update for You(22.09.2026 um 23:19 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Simplify Your Data Model with Complex Types in .NET 8

What Are Complex Types? Complex types allow us to organize related properties within an entity. Think of them as neat little bundles of data that can be reused across different parts of your application. 🎁 Why Choose Complex Ty…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

What Are Complex Types?



Complex types allow us to organize related properties within an entity. Think of them as neat little bundles of data that can be reused across different parts of your application. 🎁






Why Choose Complex Types?




  1. Cleaner Code : By using complex types, we avoid cluttering our entities with repetitive properties. Imagine an Order entity with both ShippingAddress and BillingAddress . Instead of duplicating those properties, we can create a StreetAddress complex type and reuse it wherever needed.


  2. Natural Aggregates: Unlike owned entities, which are tightly bound to their owners, complex types can be saved independently. They're like friendly companions that don't mind hanging out solo or with their owner.


  3. Implicit Keys: Complex types don't need their own keys because they're always part of a one-to-one relationship with their owner. EF Core handles this gracefully behind the scenes.







Example Time! 🚀



Take a look at picture which i provided down below ..




public class Order
{
public int Id {get;set;}
public StreetAddress ShippingAddress {get;set;}
// Other Order Properties
}
[ComplexType]
public class StreetAddress
{
public string Street {get;set;}
public string City {get;set;}
}






Let's say we have an Order class , And our StreetAddress complex type:



Now, whenever we create an order, we can easily set its shipping address using the StreetAddress complex type. No fuss, no redundancy!






Mapping Complex Types by Configuration



To map complex types using configuration over convention in EF Core, we use the IEntityTypeConfiguration interface. This allows us to define the mapping in a separate configuration class, providing more control and flexibility.



To map the StreetAddress complex type using configuration, we create a configuration class:




public class OrderConfiguration : IEntityTypeConfiguration<Order>
{
public void Configure(EntityTypeBuilder<Order> builder)
{
builder.OwnsOne(o => o.ShippingAddress, sa =>
{
sa.Property(p => p.Street).HasColumnName("ShippingStreet");
sa.Property(p => p.City).HasColumnName("ShippingCity");
});
}
}









How It Maps to the Database



When EF Core maps the StreetAddress complex type to the database, it treats the properties of the complex type as columns in the table of the owning entity. In this example, the Order table will have columns named ShippingStreet and ShippingCity.



This approach allows you to customize the column names and other aspects of the mapping, providing greater control over how your data is stored in the database.






Wrapping Up



So, my fellow devs, next time you're modeling your data in .NET 8, consider reaching for complex types. They'll keep your codebase tidy, your relationships clear, and your coffee warm.



Have you used complex types?

Share your thoughts below! Let's keep the conversation going. 🤓

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Simplify Your Data Model with Complex Types in .NET 8

Thematisch verwandte Begriffe: Simplify, Your, Data, Model · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY Kritische Sicherheitsmeldung
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick