实体框架 - 从数据库更新模型 - 新专栏

发布于 2024-08-10 03:35:35 字数 155 浏览 2 评论 0原文

当我只是向数据库中的表添加新列时,应该遵循什么流程来更新实体框架模型?我遵循的过程是在 edmx 文件中右键单击并选择“从数据库更新模型”。现在我可以根据商店中的表定义看到新字段。但是,当我查看实体本身的表映射时,我发现我的新列显示了,但没有映射到实体上的属性。我当然不需要手动向实体添加属性吗?

What is the process I should follow to update my entity framework model when I have simply added a new column to a table in the database? The process that I have followed was to right click within the edmx file and choose "Update Model from Database". Now I can see the new field against the table definition in the Store. But when I look at the table mapping for the entity itself I see that my new column shows up but is not mapped to a property on the entity. Surely I don't have to manually add a property to the entity?

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

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

发布评论

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

评论(1

虐人心 2024-08-17 03:35:35

我意识到这并不是真正的问题——唯一的问题是我对正在发生的事情的理解。我所指的新列实际上是与另一个表的外键关系,因此它确实显示为导航属性。当我向表中添加一个不是外键的列时,它会在使用“从数据库更新模型”时按预期显示。

I've realised this was not really a problem - the only problem was my understanding of what was happening. The new column I was referring to was actually a foreign key relationship with another table and therefore it did show up as a navigation property . When I go and add a column to my table that is not a foreign key it shows up as expected when using "Update Model from Database".

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