Я исправил все первичные ключи, дал update-database, но у меня есть следующая ошибка:
Я попытался исправить это с помощью установки внешних ключей, но у меня новая ошибка:
Недопустимый атрибут ForeignKeyAtt для свойства 'ID_Model' для типа 'Proiect_masini_firma_taxi.Models.Masini'.Свойство навигации «Modele_masini» не найдено в зависимом типе «Proiect_masini_firma_taxi.Models.Masini».Значение Name должно быть допустимым именем свойства навигации.
Masini.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace Proiect_masini_firma_taxi.Models
{
public enum Da_Sau_Nu
{
Da, Nu
}
public class Masini
{
[Key]
public int ID_Masina { get; set; }
public string Numar_inmatriculare { get; set; }
[ForeignKey("Modele_masini")]
public int ID_Model { get; set; }
public int An_Fabricatie { get; set; }
public int ID_proprietar { get; set; }
public Da_Sau_Nu Disponibilitate { get; set; }
public Soferi Soferi_masini { get; set; }
public Ture Ture_masini { get; set; }
public Modele_masini Masini_modele { get; set; }
internal static void ForEach(Func<object, object> p)
{
throw new NotImplementedException();
}
}
}
Modele_masini.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace Proiect_masini_firma_taxi.Models
{
public class Modele_masini
{
[Key]
public int ID_model { get; set; }
public string Nume_model { get; set; }
public string Descriere_Model { get; set; }
public ICollection<Masini> Masini_modele { get; set; }
}
}
Soferi.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace Proiect_masini_firma_taxi.Models
{
public enum DaSauNu
{
Da, Nu
}
public class Soferi
{
[Key]
public int ID_sofer { get; set; }
public string Nume { get; set; }
public string Prenume { get; set; }
public DateTime Data_nasterii { get; set; }
public string Serie_permis_de_conducere { get; set; }
public DateTime Data_Expirarii { get; set; }
public DaSauNu Angajat_curent { get; set; }
public ICollection<Ture> Soferi_ture { get; set; }
public ICollection<Masini> Soferi_masini { get; set; }
internal static void ForEach(Func<object, object> p)
{
throw new NotImplementedException();
}
}
}
Ture.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace Proiect_masini_firma_taxi.Models
{
public class Ture
{
[Key]
public int ID_tura { get; set; }
[ForeignKey("Soferi")]
public int ID_sofer { get; set; }
[ForeignKey("Masini")]
public int ID_masina { get; set; }
public DateTime Moment_Start_Tura { get; set; }
public DateTime Moment_Sfarsit_Tura { get; set; }
public DateTime Moment_logare { get; set; }
public DateTime Moment_delogare { get; set; }
public Ture Ture_Sofer { get; set; }
public Masini Ture_Masini { get; set; }
}
}