Entity Data Model Wizard Does Not Create Tables in EDMX File

I am trying to use the first approach to the database by creating an Entity Data ADO.NET data model using the wizard with DB Adventureworks2012.

Testing the connection to the DB works, and the connection string is added to App.Config.

I select all tables except those marked as (dbo) AWBuildVersion , DatabaseLog and ErrorLog .

When the wizard finishes the .edmx file empty, and if I view the file in an XML view, the EntityContainer empty.

After creating the model, it returns this error in the output window:

The model could not be created due to the following exception: 'table AdventureWorks2012.Production.Document refers to a relationship but cannot be found.

I am using VS 2010 and .NET Framework 4.0

+6
source share
3 answers

It seems that the Entity Framework does not know how to handle data types, such as hierarchyid, specified in a table field. I deleted the Production.Document table for a list of objects that included a solution to my problem.

Please note that this link is below for Adventureworks 2008R2 with EF version 1.0 from Code Plex SQL Sever, and I am using Adventureworks 2012 from the same CodePlex site using EF version 4.4.

Link: http://msftdbprodsamples.codeplex.com/wikipage?title=AW2008Details

Note. EF 1.0 Compatibility Issues

The Entity Framework team would like us to report that AdventureWorks2008 is slightly ahead of the curve in terms of the Katmai functions it uses. Some data types in AdventureWorks2008 (such as hierarchy and geometry) are not supported in the entity infrastructure. The workaround is to exclude tables such as Production.Document from your model, if possible, as there is currently no hierarchyid data type support in Entity Framework 1.0. Unfortunately, the Entity Framework tool that updates your model from the database will pull in tables such as Production.Document, even if they were specifically excluded when creating the model, so using this function in AdventureWorks2008R2 is not currently supported. We look forward to the next release of Entity Framework with full support for SQL Server 2008. Last edited May 25, 2010 at 14:22 by bonniefe, version 17

+3
source

There is a way around this if you are trying to learn from this example and are not doing anything meaningful. I deleted the foreign keys in the violation table and deleted them and was able to successfully obtain

0
source

Uncheck the [Allow Nulls] checkboxes (in the table design) for all foreign keys of non-created tables (tables that are not converted to a model).

enter image description here

Then you can update your model to get these tables by following these steps: -

Step 1 - Right-click where in your .EDMX file (ie Model1.EDMX [Diagram1]. Step 2 - then select / Update Model from the database from the context menu .... Step 3 - then select “Add”, Step 4 - then arrange the “Tables” and select the necessary tables (tables are not created for the first time). Step 5 - then click the “Finish” button. Step 6 - Save the solution and hope that everything will be fine.

enter image description here

Note. I am using Visual Studio 2013.

Good luck.

0
source

All Articles