向数据库中的表添加字段 - 如何使实体 edmx 响应?

发布于 2024-09-16 02:50:29 字数 66 浏览 12 评论 0原文

我尝试重建,但 edmx 文件似乎不会随着我所做的更改而自行更新。除了删除 edmx 并重新制作之外,还有什么建议吗?

I tried rebuilding but it seems that the edmx file doesn't update itself with the changes I made. Any suggestions besides removing the edmx and remaking it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

焚却相思 2024-09-23 02:50:35

您可以手动添加该字段。这并不难,特别是如果它是一个标量。

  1. 确保您现有的模型已签入,以防您必须回滚!
  2. 记下表中其他标量列的名称,最好具有唯一名称和相同类型。
  3. 右键单击模型,“打开方式”,XML 编辑器。
  4. 搜索其他字段。
  5. 在弹出的其他字段的任意位置添加新字段。 至少三个不同的地方需要改变。但请注意,该字段可能已经在 SSDL/存储架构中,这就是它最初没有添加的原因。
  6. 查看“错误”窗格以确保您没有弄乱 XML 有效性。
  7. 保存并编译。

现在,如果需要,您可以通过重新打开模型来编辑 GUI 中的新字段。

You can add the field manually. It's not so hard, especially if it's a scalar.

  1. Make sure your existing model is checked in in case you have to roll back!
  2. Note the name of some other scalar column in the table, preferably one with a unique name and the same type.
  3. Right click model, "Open With", XML Editor.
  4. Search for the other field.
  5. Add the new field everywhere the other field pops up. There will be at least three different places to change. But note that the field may already be in the SSDL/storage schema, which would be why it didn't add in the first place.
  6. Look at the Errors pane to make sure you haven't messed up the XML validity.
  7. Save and compile.

Now you can edit the new field in the GUI by re-opening the model, if need be.

欢你一世 2024-09-23 02:50:34

如果您使用的是 Entity Framework 4.0,则只需右键单击设计器中的空白区域,选择“从数据库更新模型”,然后单击“完成”。这将刷新所有表。

If you are using Entity Framework 4.0 you can just right-click the white-space in the designer, choose 'Update Model from Database' and hit Finish. This will refresh all tables.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文