correct entity relationship

arsar 121 Reputation points
2021-08-02T05:42:15.737+00:00

classes

public class FirmsModel  
    {  
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]  
        public int FirmId { get; set; }  
        public string Name { get; set; }  
        public virtual FirmServiceRegistraionModel firmserviceregistration_ { get; set; }  
    }  
	  
public class ServicesModel  
    {  
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]  
        public int ServiceId { get; set; }  
        public string ServiceName { get; set; }  
        public virtual ICollection<FirmServiceRegistraionModel> FirmServiceRegistraion_ { get; set; }  
    }  
	  
public class FirmServiceRegistraionModel  
    {  
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]  
        public int FirmServiceRegistrationId { get; set; }  
        public string FirmServiceRegistrationNumber { get; set; }  
		  
		  
		public int FirmId { get; set; }  
        public virtual ICollection<FirmsModel> firms_ { get; set; }  
		  
		public int ServiceId { get; set; }  
        public virtual ServicesModel services { get; set; }  
    }  
  

Every firm will be assigned a unique service in the FirmServiceRegistraion. There will be no repetition of FirmId in this table.

But one service can be assigned to multiple Firms in the FirmServiceRegistraion.

I have designed the navigational property for this, but I am confused whether it is the correct way or not. Please suggest. Thank You!!!

Attached figure shows the data in the tables.

119734-firmservice.png

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,418 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,290 questions
{count} votes