August 2017
Intermediate to advanced
330 pages
7h 26m
English
Create a Contacts class in the Models folder that corresponds to the Contacts table in the database, as follows:
using System;
using System.ComponentModel.DataAnnotations;
namespace PacktContactsCore.Model
{
public class Contacts
{
[Key]
public int Id { get; set; }
[Required]
[MinLength(4)]
public string FirstName { get; set; }
public string LastName { get; set; }
[Required]
public string Email { get; set; }
public DateTime DateOfBirth { get; set; }
}
}
With EF, we will need ContactsContext-a DbContext class-acting as a bridge between the database and the application to perform database-related operations:
using Microsoft.EntityFrameworkCore; using PacktContactsCore.Model; namespace PacktContactsCore.Context ...