简体   繁体   English

将不带键的现有表添加到实体框架模型

[英]Adding an existing table with no Key to an Entity Framework model

I have a legacy table that I need to add to my EDM via VS2012. 我有一个旧表,需要通过VS2012添加到我的EDM中。 I have updated the model via the "update model from database" menu choice. 我已经通过“从数据库更新模型”菜单选项更新了模型。 This throws the error that a key can not be inferred and adds the remarked out code to the SSDL. 这会引发无法推断密钥的错误,并将标记出的代码添加到SSDL。 I have seen references to creating a compound key in the EDM file to allow the table to be added (read only, which is fine) but have not been able to get it to work. 我已经看到了有关在EDM文件中创建复合键以允许添加表(只读,这很好)的参考,但无法使其正常工作。

It involved un-remarking the SSDL, adding a CSDL entry, and CS Mapping. 它涉及取消对SSDL的标记,添加CSDL条目和CS映射。

But I still get errors when trying to run the app about the table in question not being in the Metadata. 但是,当尝试运行有关表不在元数据中的应用程序时,我仍然遇到错误。

Any suggestions or pointers? 有什么建议或指示吗? Adding a key to the actual table is not possible in this case. 在这种情况下,无法在实际表中添加键。

TIA TIA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM