是否有任何方法可以使用Visual Studio或其他工具从SQLite数据库创建EF映射类



这是我不久前为SQL Server创建的一个。但我现在需要类似的新SQLite数据库。

public TopicMap()
{
// Primary Key
this.HasKey(t => t.TopicId);
// Identity
this.Property(t => t.TopicId)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
// Properties
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Number)
.IsRequired();
this.Property(t => t.Version)
.IsRequired()
.IsFixedLength()
.HasMaxLength(8)
.IsRowVersion();
// Table & Column Mappings
this.ToTable("Topic");
this.Property(t => t.TopicId).HasColumnName("TopicId");
this.Property(t => t.Number).HasColumnName("Number");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.SubjectId).HasColumnName("SubjectId");
this.Property(t => t.Version).HasColumnName("Version");
this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
this.Property(t => t.CreatedDate).HasColumnName("CreatedDate");
this.Property(t => t.ModifiedBy).HasColumnName("ModifiedBy");
this.Property(t => t.ModifiedDate).HasColumnName("ModifiedDate");
this.Property(t => t.Created).HasColumnName("Created");
this.Property(t => t.Modified).HasColumnName("Modified");
// Relationships
this.HasRequired(t => t.Subject)
.WithMany(t => t.Topics)
.HasForeignKey(d => d.SubjectId)
.WillCascadeOnDelete(false);
}

我现在有一个复杂的SQLite数据库,但根本找不到任何可以自动创建模型和映射类的工具。

有人知道存在的东西吗?

使用EF Core,您可以使用EF Core Power Tools。您必须安装SQLite Visual Studio工具。

更多信息请点击此处:https://github.com/ErikEJ/EFCorePowerTools/wiki/Reverse-Engineering

最新更新