using Microsoft.EntityFrameworkCore; using ReallifeGamemode.Server.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; namespace ReallifeGamemode.Server.Entities { public class GroupVehicle : ServerVehicle { public virtual Group Group { get; set; } [ForeignKey("Group")] public int? GroupId { get; set; } public override string ToString() { using(var dbContext = new DatabaseContext()) return "Gruppen Fahrzeug | Gruppe: " + dbContext.GroupVehicles.Include(g => g.Group).First(g => g.Id == this.Id).Group.Name; } } }