简体   繁体   English

实体框架将导航属性映射为标量属性

[英]Entity Framework mapping a Navigation Property as Scalar property

Im trying to generate a model from a database. 我试图从数据库生成一个模型。 The model is being generated but all the foreign key fields (that should be only navigation properties) are being mapped as Navigation Property and a scalar property (IN THE MODEL). 正在生成模型,但所有外键字段(应该只是导航属性)被映射为导航属性和标量属性(在模型中)。

I know the foreign key is added in the end of the multiplicity on database but whenever I generate a database from model, all the entity classes doesn't contain that field. 我知道在数据库的多重性末尾添加了外键,但每当我从模型生成数据库时,所有实体类都不包含该字段。

Is there a way to ignore this field generating the model from database? 有没有办法忽略从数据库生成模型的这个字段?

When you generate the model from the database there is a check box called Include foreign key columns in the model . 从数据库生成模型时,模型中有一个名为Include foreign key columns的复选框。 This check box is by default selected. 默认情况下,此复选框处于选中状态 If you deselect it your model will not contain foreign key properties but just navigation properties. 如果取消选择它,您的模型将不包含外键属性,只包含导航属性。

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

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