entity-framework - 有没有办法使用 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
推荐阅读
- java - Androidstudio 使用两个后台服务报错
- spring - Spring aop 需要一些,但不需要其他
- reactjs - 禁用今天之前的所有日期 - Ant Design Calendar
- python - 我遇到了“无法打开文件:name = 'website_model.tflearn'”,但我的 DNN 输出按原样保存在文件夹中
- javascript - 如果我不需要 SSR,如何编译 JS 文件以在 WordPress 主题中使用 React 组件?
- excel - 如何使用 VBA 打开格式错误的 csv?
- rust - 实现一个没有动态分配和编译时断言的简单状态机
- python - Python如何将pyaudio字节转换为虚拟文件?
- c# - 如何在 Unity 3D 中使用 goto 属性?
- asp.net-core - VS2019无法使用控制器模板