﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using TwitterExtractor.App.Models.DomainModel.AccessControl;

namespace TwitterExtractor.App.Models.DataModel.AccessControl.Mappers
{
    public class CredentialTwitterMap : EntityTypeConfiguration<CredentialTwitter>
    {
        public CredentialTwitterMap()
        {
            ToTable(typeof(CredentialTwitter).Name, "AccessControl");

            HasKey(c => c.IdUser);

            Property(c => c.IdUser).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(c => c.ConsumerKey).HasMaxLength(150).IsOptional();
            Property(c => c.ConsumerSecret).HasMaxLength(150).IsOptional();
            Property(c => c.AccessToken).HasMaxLength(150).IsOptional();
            Property(c => c.AccessTokenSecret).HasMaxLength(150).IsOptional();

            HasRequired(c => c.TwitterAccount).WithOptional(c => c.Credentials);
        }
    }
}