[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

How to refer entity object in code behind

Hello

I am very new in using ADO.Net 4.0 entity model. i have configured the same for MySQL using the below link
http://weblogs.asp.net/gunnarpeipman/archive/2010/12/09/getting-mysql-work-with-entity-framework-4-0.aspx
Now i am just clueless what to do next, how to refer the object to query the database.


Please help
SOS
TIA
0
ExpertHelp79
Asked:
ExpertHelp79
  • 2
  • 2
1 Solution
 
sonawanekiranCommented:
You need to create object of MySqlEntities (this name is context name when you add model to your project). For instance
var context = new MySqlEntities();
Then you call refer the entity object.
e.g. if you want all persons then
var allPersons = from p in context.Persons select p;
0
 
ExpertHelp79Author Commented:
i tried but i am not able to create
GA.edmx this i have created in the app_code section.

 <add name="GrabAdventureEntity" connectionString="metadata=res://*/App_Code.GA.csdl|res://*/App_Code.GA.ssdl|res://*/App_Code.GA.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;User Id=root;Persist Security Info=True;database=grabadventure&quot;" providerName="System.Data.EntityClient" />

this is in the web config


now when i am typing  GrabAdventureEntity it is not detecting
0
 
jagrut_patelCommented:
Can you check name of the Context class? You can check it in the Designer.cs file of the model. Expand the edmx node below it you will find this file.

Are you including the namespace in which your Model is defined? Again you can see the namespace in the same designer.cs file.
0
 
ExpertHelp79Author Commented:
Name Space for default.aspx : namespace GrabAdventure
Name space for GA. Designer.cs: namespace GrabAdventure.App_Code

how will i refer the same in default.aspx
0
 
jagrut_patelCommented:
In the Default.aspx.cs alongside other using statements put,

using GrabAdventure.App_Code;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now