I found and use EntityTypeConfiguration
public class Object
{
public int Id { get; set; }
public string Name { get; set; }
}
public class UserObject
{
[Key]
public int Id { get; set; }
public Guid UserId { get; set; }
public int ObjectId { get; set; }
public virtual Object Object { get; set; }
}
public class ObjectConfiguration: EntityTypeConfiguration<Object>
{
public ObjectConfiguration()
{
HasKey(at => new { at.Id});
Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
ToTable("Objects");
Property(t => t.Id).HasColumnName("Id");
Property(t => t.Name).HasColumnName("Name");
}
}