开发者

Entity Framework 4.0 is not Importing my Associations from Sql Server 2008 Express R2 database

开发者 https://www.devze.com 2023-01-28 10:12 出处:网络
I\'m trying to use Entity Framework 4.0 in my V开发者_Python百科S2010 project. I\'ve always used Linq to SQL for my projects with great success, and wanted to try using EF4 for a change. Unfortunately

I'm trying to use Entity Framework 4.0 in my V开发者_Python百科S2010 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消