question

arsar-2618 avatar image
0 Votes"
arsar-2618 asked arsar-2618 commented

correct entity relationship

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



dotnet-aspnet-mvcdotnet-entity-framework
firmservice.png (11.7 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @arsar-2618 ,
From your models,I think your relationship are this:
Firms<-> FireServiceRegistraion<-> Service
The Firms to FireServiceRegistraion's relationship is many to one . And Service to FireServiceRegistraion's relationship is one to many. Do you need this?
I don't understand your sample.
Best regards,
Yijing Sun

0 Votes 0 ·

@ YijingSun-MSFT Hello, Sorry I don't have any other options to clear this problem. I am unable to post questions on this site, ever time I try to post any questions shows, Access Denied
You don't have permission to access "http://docs.microsoft.com/answers/questions/ask.html" on this server.
Reference #18.c4f02817.1636619045.19977195
Why is it so, please help.

0 Votes 0 ·

0 Answers