user1117617
user1117617

Reputation:

Managing Two EDMX Files in a Solution

I am writing a web app in C# MVC.

I have two EDMX Files - One contains User tables and the other contains a single table "Pages"/"Page".

When trying to use the second EDMX locally it works fine, but on my remote environment it is saying that the entity is not part of the current context. The Database schema is identical between my local and remote database.

when I change my WebConfig to use the Remote DB I get the same error locally

What causes this and how can I resolve it?

An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code

Additional information: The entity type Page is not part of the model for the current context.

The code which falls over is.

        MyEntityConnection _database = new MyEntityConnection();

        var results = _database.Pages.Where(x => x.isDeleted == false && x.UserId == userId);

        return results;

Upvotes: 1

Views: 473

Answers (1)

user1117617
user1117617

Reputation:

Finally figured this out - after probably 12 solid hours of trying to fix it :P

In the connection string in the Web Config, the metadata (csdl/ssdl/msl) were copied from the other Connection String. To find the correct settings go to your EDMX and properties. the correct values are called "File Name"

Upvotes: 2

Related Questions