Entity framework 没有生成数据库 类
Entity framework not generating the database classes
使用 Visual Studio 2019 我最近升级了所有 NuGet 包,所以我看到 EntityFramework 现在显示为 6.2.0。我的项目是 Web API 2 解决方案。当我打开我的数据库模型并右键单击 从数据库更新模型 我可以 select 我的新 tables 但是当我保存 edmx 文件时它立即关闭.过去,它会 运行 在写入新文件时等待一段时间。
例如,在实际的 .edmx
文件本身中,我看到新添加的条目 table:
<EntityType Name="Audit_Log">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="Lab_Space_Id" Type="int" Nullable="false" />
<Property Name="Field" Type="varchar" MaxLength="80" Nullable="false" />
<Property Name="Old_Value" Type="varchar" MaxLength="1000" />
<Property Name="New_Value" Type="varchar" MaxLength="1000" />
<Property Name="Modified" Type="datetime2" Precision="7" Nullable="false" />
<Property Name="Updater" Type="int" Nullable="false" />
</EntityType>
但是,它没有为 Audit_Log class 生成相应的 class 定义。如果我完全删除 edmx 文件和 select 所有我想要的 table 加上这个新文件,它将正确生成它。
这是针对此问题的解决方法。如果您在解决方案资源管理器中展开 .edmx
文件,您将看到两个以 .tt
结尾的文件。 Right-click 并选择 运行 自定义工具 然后将生成 类。只是在 .edmx
文件上这样做对我来说不起作用。
使用 Visual Studio 2019 我最近升级了所有 NuGet 包,所以我看到 EntityFramework 现在显示为 6.2.0。我的项目是 Web API 2 解决方案。当我打开我的数据库模型并右键单击 从数据库更新模型 我可以 select 我的新 tables 但是当我保存 edmx 文件时它立即关闭.过去,它会 运行 在写入新文件时等待一段时间。
例如,在实际的 .edmx
文件本身中,我看到新添加的条目 table:
<EntityType Name="Audit_Log">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="Lab_Space_Id" Type="int" Nullable="false" />
<Property Name="Field" Type="varchar" MaxLength="80" Nullable="false" />
<Property Name="Old_Value" Type="varchar" MaxLength="1000" />
<Property Name="New_Value" Type="varchar" MaxLength="1000" />
<Property Name="Modified" Type="datetime2" Precision="7" Nullable="false" />
<Property Name="Updater" Type="int" Nullable="false" />
</EntityType>
但是,它没有为 Audit_Log class 生成相应的 class 定义。如果我完全删除 edmx 文件和 select 所有我想要的 table 加上这个新文件,它将正确生成它。
这是针对此问题的解决方法。如果您在解决方案资源管理器中展开 .edmx
文件,您将看到两个以 .tt
结尾的文件。 Right-click 并选择 运行 自定义工具 然后将生成 类。只是在 .edmx
文件上这样做对我来说不起作用。