1
votes

We are updating a project from Entity Framework 4 to Entity Framework 6. We use database first mapping. When we originally built the project we renamed many navigation properties in the entity model to improve the semantics of the property names.

When we updated to Entity Framework 6, the .edmx schema had changed, so we recreated all of the name changes. Unfortunately, at the first database access, Entity Framework throws this exception:

System.Data.Entity.Core.MetadataException was unhandled by user code
  HResult=-2146232007
  Message=Schema specified is not valid. Errors: 
The relationship 'web_appModel.fk_service_order_workorder_id' was    not loaded because the type 'web_appModel.workorder' is not available.
The following information may be useful in resolving the previous error:

The required property 'asset' does not exist on the type 'Persistence.Interface.workorder'.

Our model has a service_order table with a foreign key to a workorder table with a foreign key to an asset table. The navigation property in the workorder object was originally called asset, but we renamed it.

The problem in this case is that Entity Framework can't load a relationship a to b because because a navigation property in a relationship b to c has a changed name.

The data is in a PostgreSql database. We use DevArt DotConnect as the Entity Framework provider.

1
I have exactly the same problem. It turns out that edmx file now also specifies the navigation property name for each foreign key reference like this <NavigationProperty Name="xxx" /> As long as the name does not match the generated C# model, the DbContaxt will report a schema error. All solutions that used to work by customizing T4 template to generate customized property names now all broken. Haven't find a solution yet. - Xiaoguo Ge

1 Answers

0
votes

You need to update the EntityFramewok MODEL from data base. Double click the model, then you will find a schema of the tables, there right click any blank part and select Update Model from Database. Then go to the "Refresh" tab, and select Tables.

Hope it works for you