Roomid пользователей класса(ФК) = класс идентификационный номер(кол-во) один на один в efcodefirst
public class User { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Gender { get; set; } public string Telephone { get; set; } public string Mail { get; set; } public string TcNo { get; set; } public virtual Room RoomID { get; set; } } public class UserMap : EntityTypeConfiguration<user> { public UserMap() { HasKey(x => x.ID); Property(x => x.ID) .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); HasRequired(x => x.RoomID) .WithOptional(l => l.UserRoom) .Map(x => x.MapKey("RoomID")); } } -----------------Room-------------------------------- public class Room { public int ID { get; set; } public int? RoomNo { get; set; } public int NightFee { get; set; } public RoomType RoomType { get; set; } public RoomStatus RoomStatus { get; set; } public string Description { get; set; } public bool? Cleaning { get; set; } public bool? Available { get; set; } public DateTime CheckInDate { get; set; } public DateTime CheckOutDate { get; set; } public virtual User UserRoom { get; set; } } public class RoomMap : EntityTypeConfiguration<room> { public RoomMap() { HasKey(x => x.ID); Property(x => x.ID) .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); } }
Что я уже пробовал:
addroom.UserRoom.RoomID = adduser.RoomID; adduser.RoomID.UserRoom = addroom.UserRoom; adduser.RoomID = addroom.UserRoom.RoomID;