I am currently developing a project that functions as a contact book allowing users to add, edit, and delete contacts with information such as email, first name, last name, phone number, etc. I am exploring the possibility of enabling users to add multiple emails to a single contact.
How should I approach this task? Currently, I have one contact model linked to a SQL database table with all the necessary contact variables. Would it be advisable to create another table specifically for emails and then associate it with the main contact table?
model
namespace test1.Models
{
using System;
using System.Collections.Generic;
public partial class Contact
{
public int id { get; set; }
public string fname { get; set; }
public string lname { get; set; }
public string email { get; set; }
public Nullable<int> phonenr { get; set; }
public string address { get; set; }
}
}
Controller
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using test1.Models;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
namespace test1.Controllers
{
[Authorize]
public class ContactController : Controller
{
private ContactBookEntities1 db = new ContactBookEntities1();
// GET: Contact
public ActionResult Index()
{
return View(db.Contacts.ToList());
}
...
View to Create Contacts