-
Notifications
You must be signed in to change notification settings - Fork 0
Naming convension
Сonsider the following models:
public class MyDbContext : AnchorModelContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
string connectionString = "Server=ServerName;Database=TestDb;Integrated Security=true";
optionsBuilder.UseSqlServer(connectionString);
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.SetFKsRestrict();
base.OnModelCreating(modelBuilder);
}
public DbSet<SomeEntity> SomeEntityTableName { get; set; }
public DbSet<AnotherEntity> AnotherEntityTableName { get; set; }
} public class SomeEntity
{
[Key]
public int Id { get; set; }
[Temporary]
public string HistoricalProperty { get; set; }
public string Property { get; set; }
public int? FKId { get; set; }
public int? FKId2 { get; set; }
[Temporary]
[ForeignKey(nameof(FKId))]
public AnotherEntity HistoricaAnotherEntityProperty { get; set; }
[ForeignKey(nameof(FKId2))]
public AnotherEntity AnotherEntityProperty { get; set; }
}
public class AnotherEntity
{
[Key]
public int Id { get; set; }
[Temporary]
[Column(TypeName = "numeric(15, 3)")]
public decimal HistoricalProperty { get; set; }
}The plugin will generate the following:
From entity SomeEntity:
- A_SomeEntityTableName
- P_H_SomeEntityTableName_HistoricalProperty
- P_SomeEntityTableName_Property
From entity AnotherEntity:
- A_AnotherEntityTableName
- P_H_AnotherEntityTableName_HistoricalProperty
And ties:
- T_H_SomeEntityTableName_HistoricaAnotherEntityProperty_to_AnotherEntityTableName
- T_SomeEntityTableName_AnotherEntityProperty_to_AnotherEntityTableName
It is an anchor. SomeEntityTableName coming from MyDbContext property.
public class A_SomeEntityTableName
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int Id { get; set; }
public int TrnId { get; set; }
public int? CloseTrnId { get; set; }
[ForeignKey("TrnId")]
public Transaction Transaction { get; set; }
[ForeignKey("CloseTrnId")]
public Transaction CloseTransaction { get; set; }
}It is an anchor historized attribute. SomeEntityTableName coming from MyDbContext property. HistoricalProperty coming from SomeEntity property.
public class P_H_SomeEntityTableName_HistoricalProperty
{
[CompositeKey]
public int A_Id { get; set; }
[ForeignKey("A_Id")]
public A_SomeEntityTableName Anchor { get; set; }
public string Value { get; set; }
[CompositeKey]
public DateTime ApplTime { get; set; }
[CompositeKey]
public int TrnId { get; set; }
public int? CloseTrnId { get; set; }
[ForeignKey("TrnId")]
public Transaction Transaction { get; set; }
[ForeignKey("CloseTrnId")]
public Transaction CloseTransaction { get; set; }
}It is an anchor static attribute. SomeEntityTableName coming from MyDbContext property. Property coming from SomeEntity property.
public class P_SomeEntityTableName_Property
{
[CompositeKey]
public int A_Id { get; set; }
[ForeignKey("A_Id")]
public A_SomeEntityTableName Anchor { get; set; }
public string Value { get; set; }
[CompositeKey]
public int TrnId { get; set; }
public int? CloseTrnId { get; set; }
[ForeignKey("TrnId")]
public Transaction Transaction { get; set; }
[ForeignKey("CloseTrnId")]
public Transaction CloseTransaction { get; set; }
}It is an historized tie. SomeEntityTableName coming from MyDbContext property. HistoricaAnotherEntityProperty coming from SomeEntity property. AnotherEntityTableName coming from MyDbContext property.
public class T_H_SomeEntityTableName_HistoricaAnotherEntityProperty_to_AnotherEntityTableName
{
[CompositeKey]
public int A_Id { get; set; }
[CompositeKey]
public int ToId { get; set; }
[ForeignKey("A_Id")]
public A_SomeEntityTableName Anchor { get; set; }
[ForeignKey("ToId")]
public A_AnotherEntityTableName ToAnchor { get; set; }
[CompositeKey]
public DateTime ApplTime { get; set; }
[CompositeKey]
public int TrnId { get; set; }
public int? CloseTrnId { get; set; }
[ForeignKey("TrnId")]
public Transaction Transaction { get; set; }
[ForeignKey("CloseTrnId")]
public Transaction CloseTransaction { get; set; }
}It is an static tie. SomeEntityTableName coming from MyDbContext property. AnotherEntityProperty coming from SomeEntity property. AnotherEntityTableName coming from MyDbContext property.
public class T_SomeEntityTableName_AnotherEntityProperty_to_AnotherEntityTableName
{
[CompositeKey]
public int A_Id { get; set; }
[CompositeKey]
public int ToId { get; set; }
[ForeignKey("A_Id")]
public A_SomeEntityTableName Anchor { get; set; }
[ForeignKey("ToId")]
public A_AnotherEntityTableName ToAnchor { get; set; }
[CompositeKey]
public int TrnId { get; set; }
public int? CloseTrnId { get; set; }
[ForeignKey("TrnId")]
public Transaction Transaction { get; set; }
[ForeignKey("CloseTrnId")]
public Transaction CloseTransaction { get; set; }
}