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:
- Right click on my project in VS2010 solution explorer
- Click Add => New Item...
- Select 'ADO.NET Entity Data Model'
- Select 'Generate from database'
- Connect to my SQL 2008 Express R2 database
- Check the 'Tables' item
- Pluralize or singularize generated object names is CHECKED
- Include foreign key columns in the model is CHECKED
- 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.
精彩评论