Skip to content

Instantly share code, notes, and snippets.

@mikecole
Created October 30, 2013 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikecole/7237306 to your computer and use it in GitHub Desktop.
Save mikecole/7237306 to your computer and use it in GitHub Desktop.
Migrations Author Class Change
public class Author : EntityBase
{
public Author()
{
Posts = new Collection<Post>();
}
public string Name { get; set; }
public string TwitterHandle { get; set; }
public string Email { get; set; } //<-- right there
public virtual ICollection<Post> Posts { get; set; }
public virtual JobTitle JobTitle { get; set; }
}
public class AuthorConfiguration : EntityTypeConfiguration<Author>
{
public AuthorConfiguration()
{
HasKey(author => author.ID);
Property(author => author.Name).HasMaxLength(50).IsRequired();
Property(author => author.TwitterHandle).HasMaxLength(50);
Property(author => author.Email).HasMaxLength(50); //<-- and there
HasOptional(author => author.JobTitle)
.WithMany(title => title.Authors)
.Map(author => author.MapKey("JobTitleID"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment