Hi Ladislav,
You can also customize the complex type columns names at the entity level with fluent API in EF 4.1. Here is an example:
public class User
{
public int UserId { get; set; }
public Address Address { get; set; }
}
public class Customer
{
public int CustomerId { get; set; }
public Address Address { get; set; }
}
[ComplexType]
public class Address
{
public string Street { get; set; }
public string City { get; set; }
}
public class Context : DbContext
{
public DbSet<User> Users { get; set; }
public DbSet<Customer> Customers { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<User>().Property(u => u.Address.Street)
.HasColumnName("UserStreet");
modelBuilder.Entity<Customer>().Property(u => u.Address.Street)
.HasColumnName("CustomerStreet");
}
}
You can find another example here.
Hope this helps,
Morteza