Does any know if one can set the table schema of code first classes based on the classes\' namespace?
For example, every class in namespace Core.Foo
would
I will add one thing to what octavioccl provided. If you would like to preserve table name pluralization, you can use built-in pluralization service like this:
using System.Data.Entity.Infrastructure.DependencyResolution;
public class CustomSchemaConvention : Convention
{
public CustomSchemaConvention()
{
var pluralizationService = DbConfiguration.DependencyResolver.GetService();
Types().Configure(c => c.ToTable(
pluralizationService.Pluralize(c.ClrType.Name),
c.ClrType.Namespace.Substring(c.ClrType.Namespace.LastIndexOf('.') + 1))
);
}
}