lilypad49
asked on
How to Create Model Container Object
I asked this question a while back but no one was a able to tackle it. So I did some more testing and determined it is in my code that the problem exists. So my question is, what am I doing wrong?
So I create the model container:
Thinking maybe I was doing something wrong I changed it over to the first way, then I do:
This is the error it gives me on the Immediate window:
Is there something I can do to make this error go away? I tried deleting the project and recreating it with my old .edmx model that I downloaded from Mozy from when it used to work. It stopped working (as far as I can tell) after I changed the .edmx model and updated it. Maybe I did something else in the other project too, but I'm not recalling anything.
So I create the model container:
Private mdbContext As PFModelContainer
Private mdbTransactions As Object
Before I did it this way:Private mdbContext As New PFModelContainer
Private mdbTransactions As mdbContext.Transactions
Thinking maybe I was doing something wrong I changed it over to the first way, then I do:
Public Sub New()
mdbContext = New PFModelContainer
mdbTransactions = mdbContext.Transactions
End Sub
Once I hit
mdbContext = New PFModelContainer
it takes me over to the
PFModel.Designer.vbWhere it steps through the following:
Public Sub New()
MyBase.New("name=PFModelContainer", "PFModelContainer")
At which point it terminates execution of the code. Am I doing something wrong here?This is the error it gives me on the Immediate window:
A first chance exception of type 'System.ArgumentException'occurred in System.Data.Entity.dll
Is there something I can do to make this error go away? I tried deleting the project and recreating it with my old .edmx model that I downloaded from Mozy from when it used to work. It stopped working (as far as I can tell) after I changed the .edmx model and updated it. Maybe I did something else in the other project too, but I'm not recalling anything.
What version of the Entity Framework are you using? Are you using 2010 IDE?
ASKER
I'm using VB Visual Studio Express 2010. I'm using the Entity Framework version that comes with it. I'm assuming it is the latest version.
No, Entity Framework 4.1 Update 1 is the most current version that I know of.
ADO.NET Entity Framework 4.1 - Update 1
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=26825
The first chance exception is a warning, and usually doesn't affect anything. What is the context for the exception (when does it occur, design time, run time, ...)?
ADO.NET Entity Framework 4.1 - Update 1
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=26825
The first chance exception is a warning, and usually doesn't affect anything. What is the context for the exception (when does it occur, design time, run time, ...)?
ASKER
I updated it to version 4.1 but the error still occurs.
Yes, it would be nice if it didn't affect anything, unfortunately it stops the code dead in its tracks, it doesn't break, just stops stepping through the code.
It occurs while in debug mode both when I'm stepping through it and if I don't step through.
Yes, it would be nice if it didn't affect anything, unfortunately it stops the code dead in its tracks, it doesn't break, just stops stepping through the code.
It occurs while in debug mode both when I'm stepping through it and if I don't step through.
I don't quite have the "big picture". How did you generate the Model in the .edmx file?
ASKER
I created the .edmx file by using the IDE to create .edmx files. In other words I started from scratch and put everything together using the blocks, etc.
I don't use the Entity Framework very much, but when you installed 4.1 Update 1, did it upgrade the reference for the Entity Framework (higher version), or can you have side-by-side installation?
ASKER
I only found the one entity framework in the folder:
Called:
Version:
I searched the whole "Program Files" for "EntityFramework.dll"
C:\Program Files\Microsoft ADO.NET Entity Framework 4.1\Binaries
Called:
EntityFramework.dll
Version:
4.1.10715.0
I searched the whole "Program Files" for "EntityFramework.dll"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, it turns out that I need to update the tt model by right clicking in the edmx model and pressing
Then
I don't remember doing that before, but I must have.
Well, TheLearnedOne, you got the ideas in my had flowing, so I'll award you points.
Add Code Generation Item
Then
ADO.NET DbContext Generator
I don't remember doing that before, but I must have.
Well, TheLearnedOne, you got the ideas in my had flowing, so I'll award you points.
ASKER
Thanks, TheLearnedOne. It was nice to get the thought process going and to have downloaded the Entity update.
Aha, good to know about the T4 template problem. I wouldn't have thought of that!!