In the model generated by the following code, all of the string properties should be Unicode strings as specified by the second convention. These conventions should be applied in the order they are declared and all of the string properties should be marked as Unicode. The way they currently are applied, Types() conventions always seem to take precedence over Properties() conventions and we end up with the Text property being set to IsUnicode = false and the rest of the string properties to IsUnicode = true
Code:
```
public class BlogContext : DbContext
{
public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Types<Base>().Configure(t => t.Property(b => b.Text).IsUnicode(false));
modelBuilder.Properties<String>().Configure(p => p.IsUnicode(true));
}
}
public class Base
{
public int ID { get; set; }
public string Text { get; set; }
public string Author { get; set; }
public DateTime PublishDate { get; set; }
}
public class Comment : Base
{
public int PostId { get; set; }
}
public class Post : Base
{
public string Title { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
```
Code:
```
public class BlogContext : DbContext
{
public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Types<Base>().Configure(t => t.Property(b => b.Text).IsUnicode(false));
modelBuilder.Properties<String>().Configure(p => p.IsUnicode(true));
}
}
public class Base
{
public int ID { get; set; }
public string Text { get; set; }
public string Author { get; set; }
public DateTime PublishDate { get; set; }
}
public class Comment : Base
{
public int PostId { get; set; }
}
public class Post : Base
{
public string Title { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
```