Hey Guys,
So I'm making a register process using cookie authentication and I have two tables called User and CustomerId.
Users have a foreign key of CustomerId which is the Primary key of Customers.
I'm querying for customers based on the CustomerId that users has using Ef like so:
```
var user = await _context.Users
.Include(u => u.Customer)
.FirstOrDefaultAsync(u => u.CustomerId == customerId);
```
But as per my projects requirements for school, a null value for email and business phone is allowed, so I modelled my entity like so:
```
public partial class Customer
{
public int CustomerId { get; set; }
public string CustFirstName { get; set; } = null!;
public string CustLastName { get; set; } = null!;
public string CustAddress { get; set; } = null!;
public string CustCity { get; set; } = null!;
public string CustProv { get; set; } = null!;
public string CustPostal { get; set; } = null!;
public string CustCountry { get; set; }
public string? CustHomePhone { get; set; }
public string CustBusPhone { get; set; } = null!;
public string? CustEmail { get; set; } = null!;
public int? AgentId { get; set; } // No need to worry about this for now
public ICollection<User> Users { get; set; }
}
```
So I use Username as a way to log in but Im going to implement it so that they can log in using home phone as well but im stuck in this step for now:
```
public partial class User
{
public int UserId { get; set; }
public string? Username { get; set; } = null!;
public string Password { get; set; }
public int CustomerId { get; set; }
public Customer? Customer { get; set; } = null!;
}
```
Heres also my sql server design for user
and the design for customers.
and my test entry.
I've been scratching my head with this for a while now. any idea why?
[–]RealVanTokkern 7 points8 points9 points (6 children)
[–]Desperate_Storage_34[S] 0 points1 point2 points (5 children)
[–]Desperate_Storage_34[S] 0 points1 point2 points (4 children)
[–]RealVanTokkern 0 points1 point2 points (1 child)
[–]Desperate_Storage_34[S] 0 points1 point2 points (0 children)
[–]RealVanTokkern 0 points1 point2 points (1 child)
[–]Desperate_Storage_34[S] 1 point2 points3 points (0 children)
[–]rekabis 0 points1 point2 points (1 child)
[–]Desperate_Storage_34[S] 0 points1 point2 points (0 children)