Relationship between tables

necrontyre

New Member
I use \[code\]sqlmembership provider\[/code\] and that creates some tables. I need its \[code\]user\[/code\] table.My application has three types of users: \[code\]teachers\[/code\], \[code\]students\[/code\] and \[code\]other users\[/code\]. So I thought of three tables for them. Each of them has a \[code\]username\[/code\] which is registered by membership provider and saved in its own tables.Now I don't know how to make the relationship between \[code\]teachers\[/code\] or \[code\]students\[/code\] tables to their usernames saved in the table of memberships, using entity framework.I thought I can add a one to one relationship between \[code\]users\[/code\] table created by membership provider and my tables after reverse engineering created tables by it to code first, but it seems is not allowed to change those tables.Can someone show me how to make a relationship between teachers or students to their usernames (I mean their membership information)?More Details: here are code first tables\[code\]public class aspnet_Users{ public aspnet_Users() { this.aspnet_PersonalizationPerUser = new List<aspnet_PersonalizationPerUser>(); this.aspnet_Roles = new List<aspnet_Roles>(); } public System.Guid ApplicationId { get; set; } public System.Guid UserId { get; set; } public string UserName { get; set; } public string LoweredUserName { get; set; } public string MobileAlias { get; set; } public bool IsAnonymous { get; set; } public System.DateTime LastActivityDate { get; set; } public virtual aspnet_Applications aspnet_Applications { get; set; } public virtual aspnet_Membership aspnet_Membership { get; set; } public virtual ICollection<aspnet_PersonalizationPerUser> aspnet_PersonalizationPerUser { get; set; } public virtual aspnet_Profile aspnet_Profile { get; set; } public virtual ICollection<aspnet_Roles> aspnet_Roles { get; set; }}public class Techer{ [Key] public int TeacherId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string NationalNumber { get; set; } public string PhoneNumber { get; set; } public string Description { get; set; } public int OfficeId { get; set; } public virtual Office Office { get; set; }}public class Student{ public int StudentId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public int OfficeId { get; set; } public virtual Office Office { get; set; }}\[/code\]
 
Back
Top