15

I'm getting a weird EF4 "Entity Framework v4" error when I do a select on the context:

Schema specified is not valid. Errors: The relationship 'AnalyzerConfigurationModel.FK_AnalyzerMetadataParameters_AnalyzerMetadata' was not loaded because the type 'AnalyzerConfigurationModel.AnalyzerMetadataParameter' is not available.

The query to generate the error is:

Using context As New AnalyzerConfigurationEntities
      Dim EFAnalyzerConfiguration = (From P In context.AnalyzerConfigurations
                                     Where P.Name = analyzerConfigurationName).FirstOrDefault
End Using

The schema is show below. alt text

I've checked the connection strings, multiple times, its not that. Everything looks fine. I'm not sure if the XML that gets generated from this schema is off or not. But looked there too and don't see anything off or different from other properties. Has anyone run into this one before?

TylerH
  • 20,799
  • 66
  • 75
  • 101
irperez
  • 1,771
  • 2
  • 22
  • 26

4 Answers4

17

I found that if I expanded the EDMX file in solution explorer (VS 2012) and right clicked on each .tt file and selected Run Custom Tool also fixed the issue. This might be easier than de

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
CWaters
  • 175
  • 1
  • 4
6

Also make sure you're referencing project has the EntityFramework installed otherwise the dependent code will get this error.

https://www.nuget.org/packages/EntityFramework

dynamiclynk
  • 2,275
  • 27
  • 31
1

Let me explain this:

The problem is because the system did not find consistency of the columns in database, the entities in the .edmx file and the model class and also the use of the same in the controller class.

So follow the following steps to fix this up:

  1. Go to the database, check all the column names and properties.
  2. Confirm them with the class diagram in the.edmx file. Right-click on the class in which you are getting the error, and select update option for the class. Select the Refresh tab in dialogue (if there is no new column added. if new column is added, you can select the add tab.) and select the relevant objects. Generally they are tables. So select them and finish.
  3. Next check the names in the model class and the controller class.

This should be the solution. If not, let me know.

Tushar Sharma
  • 347
  • 1
  • 3
  • 11
0

Are you using the SelfTracking Entity T4 template? I had this issue and found out the T4 template was not re-generating my entities after I had changed the Entity model in the Entity Designer. Try to right click the T4 Template and click "Run custom tool", and see if that helps.

John Egbert
  • 5,496
  • 8
  • 32
  • 44