Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

folgendes Problem:

Ich will mit dem EF 4 (Code First Ansatz) eine kleine Anwendung basteln. Es gibt Projekte, Kategorien und einen Status. Ein Projekt hat einen Status, genau wie eine Kategorie. Und beim anlegen der DB durch das EF wird gemeckert dass es ein zyklischer Verweis ist.... hat jemand ne spontane Idee wie ich das lösen kann bzw. wie ich ihm beibiege dass es ok so ist?!

Danke + Grüße

  • Autor

So in etwa sieht der Code bzw. das Modell aus:

Status:

[Key]

int ID

string Name

Projekt:

[Key]

int ID

string Name

[ForeignKey]

int StatusId

virtual Status CurrentStatus

Kategorie:

[Key]

int ID

string Name

[ForeignKey]

int ProjektId

virtual Projekt CurrentProjekt

[ForeignKey]

int StatusId

virtual Status CurrentStatus

Reicht das um den Gedanken dahinter bzw. das Problem zu verstehen?!

Also Projekt verweist auf Status und Kategorie verweist auf Projekt und Status? Da ist keine zyklische Abhängigkeit drin vorhanden.

Allerdings verstehe ich auch den Aufbaue nicht. Warum hat eine Kategorie einen Status und warum ein Projekt? Eigentlich müsste doch das Projekt eine Kategorie haben

  • Autor

Nachdem ich den Status aus den Objekten entfernt hatte, war alles ok.

Ein Projekt kann den Status "Valide" haben. Eine Kategorie des Projekts kann aber durch aus den Status "Invalide" haben. Denke das ist nicht so abwägig...

So in etwa sieht der Code bzw. das Modell aus:

Eine Verständnisfrage: Soll wirklich jede Kategorie nur ein Projekt haben?

Oder sollte nicht ein Projekt eine Kategorie haben und eine Kategorie vielen Projekten zugeordnet werden können, sprich: passen die Kardinalitäten so?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.