Entity Framework 4.0 未从 Sql Server 2008 Express R2 数据库导入我的关联

发布于 2024-10-05 02:11:12 字数 733 浏览 1 评论 0原文

我正在尝试在我的 VS2010 项目中使用 Entity Framework 4.0。我一直在我的项目中使用 Linq to SQL 并取得了巨大成功,并且想尝试使用 EF4 进行更改。不幸的是,当我执行将 EF4 模型添加到项目中的步骤时,没有创建任何关联。

以下是我的步骤:

  1. 在 VS2010 解决方案资源管理器中右键单击我的项目
  2. 单击添加=>新项目...
  3. 选择“ADO.NET 实体数据模型”
  4. 选择“从数据库生成”
  5. 连接到我的 SQL 2008 Express R2 数据库
  6. 检查“表”项目
    1. 已检查生成的对象名称的复数或单数
    2. 已检查模型中是否包含外键列
  7. 单击“完成”!

我看到了所有表格,但它们之间没有任何关联。当使用“Linq to SQL Classes”项时,我的所有关联都会按照我的预期生成。即使我在 EF4 设置过程中将其简化为仅包含两个(关联)表,关联仍然不会显示。

我尝试通过 EF 数据模型设计器手动添加关联,但在调试项目时会生成其他错误。这些错误表明我的命名数据库关联在数据库中配置不正确。

更新:我认为这是 EF4 的一个错误,但看起来好像我在约束/关联中遗漏了一些东西。我将从头开始重建一些表格,看看是否有帮助。我的数据库是从 SQL CE 3.5 转换而来的,所以我可能错过了一些东西。

谢谢

I'm trying to use Entity Framework 4.0 in my VS2010 project. I've always used Linq to SQL for my projects with great success, and wanted to try using EF4 for a change. Unfortunately when I go through the steps to add EF4 model to my project, none of my associations are created.

Here are my steps:

  1. Right click on my project in VS2010 solution explorer
  2. Click Add => New Item...
  3. Select 'ADO.NET Entity Data Model'
  4. Select 'Generate from database'
  5. Connect to my SQL 2008 Express R2 database
  6. Check the 'Tables' item
    1. Pluralize or singularize generated object names is CHECKED
    2. Include foreign key columns in the model is CHECKED
  7. Click Finish!

I see all of my tables, but there are no associations between any of them. When using the 'Linq to SQL Classes' item, all of my associations are generated as I would expect. Even when I dumb it down to only include two (associating) tables during the EF4 setup process, the associations still don't show up.

I've tried manually adding the assoications through the EF data model designer, but it generates other errors when debugging the project. The errors indicate that my named database associations are not configured correctly in the database.

UPDATE: I thought it was a bug with EF4, but it appears as though I'm missing something in the constraints / associations. I'm going to rebuild some of my tables from scratch and see if that helps. My db was converted from SQL CE 3.5, so I may have missed something along the way.

Thanks

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

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

发布评论

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

评论(1

爱的那么颓废 2024-10-12 02:11:12

我认为这是 EF4 的一个错误,但看起来好像我在约束/关联中遗漏了一些东西。我从头开始重建了一些桌子,它解决了我的问题。

I thought it was a bug with EF4, but it appears as though I'm missing something in the constraints / associations. I rebuilt some of my tables from scratch and it fixed my problem.

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