简体   繁体   English

实体框架3.5未在模型中添加所有属性

[英]Entity Framework 3.5 Not adding all Properties in Model

I'm experiencing an unusual issue with Entity Framework in VS2008. 我在VS2008中遇到了Entity Framework的不寻常问题。 The problem is when I create my Entity Model from my existing database, the designer add all the corresponding tables but it appears that it randomly omits some of my Foreign Key fields. 问题是,当我从现有数据库创建实体模型时,设计人员添加了所有对应的表,但看起来它随机地忽略了一些外键字段。 Yet if I browse the Model in the Browser I can clearly see that the fields were included. 但是,如果我在浏览器中浏览模型,则可以清楚地看到其中包含了字段。

This became apparent when during the build I started receiving multiple errors that these fields were not mapped. 当我在构建期间开始收到多个错误(这些字段未映射)时,这一点变得显而易见。 This led me to manually add the fields in the designer to the corresponding tables and map them to the datasource. 这导致我手动将设计器中的字段添加到相应的表中,并将它们映射到数据源。

After this however, I get multiple errors: Error 102 Error 10023: Could not find the conceptual model to validate. 但是,此后,我得到多个错误:错误102错误10023:无法找到要验证的概念模型。
Error 103 Error 10024: Could not find the storage model to validate. 错误103错误10024:找不到要验证的存储模型。
Error 104 Error 10025: Could not find the mapping model to validate. 错误104错误10025:找不到要验证的映射模型。
Error 105 Could not find the Conceptual Schema node to embed as a resource for input file Error 106 Could not find the Storage Schema node to embed as a resource for input file Error 107 Could not find the Mapping node to embed as a resource for input file 错误105找不到概念模式节点作为输入文件的资源嵌入错误106找不到存储模式概念节点作为输入文件的资源嵌入错误107找不到映射节点作为输入文件的资源嵌入

When I open the edmx file in XML Editor, the file is riddled with squiggly lines. 当我在XML编辑器中打开edmx文件时,该文件到处都是波浪线。

I have successfully created the Entity Model in VS2010 without issue but our client isn't at 4.0 Framework. 我已经成功地在VS2010中成功创建了实体模型,但是我们的客户端不是4.0框架。

I have identified others having the issue but I can't find any resources to assist on fixing the problem. 我发现其他人有问题,但是我找不到任何资源来帮助解决问题。

Any suggestions would be greatly appreciated. 任何建议将不胜感激。

This is probably EF1 did not support foreign keys. 这可能是EF1不支持外键。 So for foreign key columns EF will create navigation properties but will not create foreign key properties on the Entities. 因此,对于外键列,EF将创建导航属性,但不会在实体上创建外键属性。 You can find foreign properties in model browser but this is in the model representing the database and not the conceptual model. 您可以在模型浏览器中找到外部属性,但这位于代表数据库的模型中,而不是概念模型。 Note that navigation properties are modeled based on foreign keys in the store and you are not losing the relationship functionality even though you don't have foreign keys exposed. 请注意,导航属性是基于商店中的外键建模的,即使您没有暴露外键,您也不会失去关系功能。 In other words - if you use navigation properties in queries they will be translated correctly to use foreign key values in the SQL queries. 换句话说,如果您在查询中使用导航属性,它们将被正确转换以在SQL查询中使用外键值。 One thing where having foreign key properties in the conceptual model is very useful is when you would like to reason or modify a relationship without having to load the related entity - if you know the key value you just set the foreign key property to this value and you are done with it. 在概念模型中具有外键属性非常有用的一件事是,您想推理或修改关系而不必加载相关实体-如果您知道键值,只需将外键属性设置为该值,然后您已经完成了。 This is impossible in EF1 - whenever you need to change the relationship or query against a related entity you first need to load said entity and use navigation property. 在EF1中这是不可能的-每当您需要更改关系或对相关实体进行查询时,您首先需要加载该实体并使用导航属性。

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

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