Sry for my bad English. I'm currently learning ASP.NET Core with Angular and I have some problems.
I have a database of two tables with these fields(I deleted some fields that are not necessary to show). AccountId in Employee is a Foreign Key to PrimaryKey AccountId in Account table.
public class Employee
{
public int EmployeeId{get;set ;}
public string EmployeeFullName { get; set; }
public string PhoneNumber { get; set; }
public int AccountId { get; set; }
}
public class Account
{
public int AccountId {get;set;}
public string Username { get; set; }
public string Password { get; set; }
}
How can I create models with the relationship above using Code first EF? I tried something I read on some pages like:
public Account AccountId{get;set;}
but it didn't work.
In Angular, I already have a form with those fields in Employee(except EmployeeId and AccountId). I can insert, delete, adjust, show data from SQL server Database but I can interact with one table only (Employee). Cause I created API Controller with Employee model and DbSet from DbContext.
How can I use one form from Angular but insert(API Post) to two tables at once. I want to use the form to insert employee data into the database (Employee table) and create the account (Account table) using for login with Username is PhoneNumber and a Default Password which they can change later.