Open Xiaolefu93 opened 1 month ago
the Product and Category entity:
public class Category :AuditedAggregateRoot<Guid>
{
public string Name { get; set; }
}
public class Product : FullAuditedAggregateRoot<Guid>
{
public Category Category { get; set; }
public Guid CategoryId { get; set; }
public string Name { get; set; }
public float Price { get; set; }
public bool IsFreeCargo { get; set; }
public DateTime ReleaseTime { get; set; }
public ProductStockState StockState { get; set; }
}
Add ConfigureByConvention();
builder.Entity<Category>(c =>
{
c.ConfigureByConvention();
c.ToTable("Categories");
c.Property(x => x.Name).HasMaxLength(CategoryConst.MaxNameLength).IsRequired();
c.HasIndex(x => x.Name);
});
builder.Entity<Product>(p =>
{
p.ConfigureByConvention();
p.ToTable("Products");
p.Property(x => x.Name).HasMaxLength(ProductConst.MaxNameLength).IsRequired();
p.HasIndex(x => x.Name).IsUnique();
p.HasOne(x => x.Category).WithMany().HasForeignKey(x => x.CategoryId).OnDelete(DeleteBehavior.Restrict).IsRequired();
});
thank you,and then I want to ask "why add ConfigureByConvention"
Is there an existing issue for this?
Description
hi,when I try "dotnet ef migrations",get the error "The exception 'The entity type 'ExtraPropertyDictionary' requires a primary key to be defined". And then I try add [key]attribute in the entity or add p.HasKey(x => x.Id) in OnModelCreating,but get the same error "The exception 'The entity type 'ExtraPropertyDictionary' requires a primary key to be defined"
namespace BoilerPlateLayer.EntityFrameworkCore;
[ReplaceDbContext(typeof(IIdentityDbContext))] [ReplaceDbContext(typeof(ITenantManagementDbContext))] [ConnectionStringName("Default")] public class BoilerPlateLayerDbContext : AbpDbContext,
IIdentityDbContext,
ITenantManagementDbContext
{
/ Add DbSet properties for your Aggregate Roots / Entities here. /
}
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
8.3.0
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response