public class Company
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Key, Column(TypeName = "varchar"), MaxLength(50)]
public string UserId { get; set; }
}
public class CompanyConfiguration : EntityTypeConfiguration<Company>
{
public CompanyConfiguration()
{
//for query purpose only
Property(c => c.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
{
public CompanyConfiguration()
{
//for query purpose only
Property(c => c.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
//this is the Key to One-to-One/Zero relationship
HasKey(c => c.UserId);
}
}