Solved

How to Create Model Container Object

Posted on 2011-09-09
12
748 Views
Last Modified: 2012-05-12
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:

Private mdbContext As PFModelContainer
Private mdbTransactions As Object

Open in new window

Before I did it this way:

Private mdbContext As New PFModelContainer
Private mdbTransactions As mdbContext.Transactions

Open in new window


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

Open in new window

Once I hit
mdbContext = New PFModelContainer

Open in new window

it takes me over to the
PFModel.Designer.vb
Where it steps through the following:

Public Sub New()
  MyBase.New("name=PFModelContainer", "PFModelContainer")

Open in new window

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.
0
Comment
Question by:lilypad49
  • 6
  • 6
12 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 36516904
What version of the Entity Framework are you using?  Are you using 2010 IDE?
0
 

Author Comment

by:lilypad49
ID: 36518284
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 36518889
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, ...)?
0
 

Author Comment

by:lilypad49
ID: 36524490
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 36525313
I don't quite have the "big picture".  How did you generate the Model in the .edmx file?
0
 

Author Comment

by:lilypad49
ID: 36525847
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.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 36526192
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?
0
 

Author Comment

by:lilypad49
ID: 36527297
I only found the one entity framework in the folder:

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"
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 36528620
Does the project reference show that this file is the one that is being used?  I wanted to make sure, so that we don't go off on a tangent, when it is still using the old framework version.
0
 

Author Comment

by:lilypad49
ID: 36533169
OK, it turns out that I need to update the tt model by right clicking in the edmx model and pressing

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.
0
 

Author Closing Comment

by:lilypad49
ID: 36533181
Thanks, TheLearnedOne. It was nice to get the thought process going and to have downloaded the Entity update.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 36533631
Aha, good to know about the T4 template problem.  I wouldn't have thought of that!!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Updating ms sql with special characters 8 40
Merge Statement 3 39
user defined date datatype in SQL Server- can it be overdone.. 6 23
Sql Query 4 16
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now