实体框架 - 从数据库更新模型 - 新专栏
当我只是向数据库中的表添加新列时,应该遵循什么流程来更新实体框架模型?我遵循的过程是在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到这并不是真正的问题——唯一的问题是我对正在发生的事情的理解。我所指的新列实际上是与另一个表的外键关系,因此它确实显示为导航属性。当我向表中添加一个不是外键的列时,它会在使用“从数据库更新模型”时按预期显示。
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".