context.Attachto( "Tables",
com); //here I got compile error on AttachTo method with red line under it.it says "Project1.TestEntities does not contain a definition for 'Attachto' and no extension method 'Attachto' accepting a first argument of type 'Project1.TestEntities' could be found
(are you missing a using directive or an assembly reference?)"
context.saveChanges();
}
Does anybody know what is missing in my project, (namespace or reference?) I am using VS2102 version.thanks
a lot
Are you using an ObjectContext or a DbContext? DbContext does not have the AttachTo method.
Make sure that the System.Data.Entity assembly has been referenced in your project, especially if you're using class library that contains your EDM.
Hi, Thanks for the help,
I am not sure what do you mean the ObjectContext, from my code you can see that basically, I am using entitydata model in my project.
I get the context of entity data model first and then use it.
This is the example I was followed it. The first example of Retrieve is working fine, but the second one (Delete and Update example) which use AttachTo does not work. Yes, I have System.Entity.Data in my reference. since I am using VS2012, I think all of
these reference are automatically included.
From your error message, it seems that Project1.TestEntities didn't contain 'Attachto' method. Have you tried to use
"context.AttachTo( "Tables", com);" in your code? If so, please try to use this code. It will make sense.
Peter Cong
Member
527 Points
681 Posts
Why my entity does not recognize AttachTo() method?
Dec 19, 2012 11:52 PM|LINK
Hi, I am using entityFramework in web form project.
This is my codes:
protected void DeleteARow_Click(object sender, EventArgs e) {
TestEntities context = new TestEntities();
Table1 com = new Table1 { CommitId = 2,
};
context.Attachto( "Tables", com); //here I got compile error on AttachTo method with red line under it.it says "Project1.TestEntities does not contain a definition for 'Attachto' and no extension method 'Attachto' accepting a first argument of type 'Project1.TestEntities' could be found (are you missing a using directive or an assembly reference?)"
context.saveChanges();
}
Does anybody know what is missing in my project, (namespace or reference?) I am using VS2102 version.thanks a lot
Careed
All-Star
18774 Points
3637 Posts
Re: Why my entity does not recognize AttachTo() method?
Dec 20, 2012 05:56 AM|LINK
Are you using an ObjectContext or a DbContext? DbContext does not have the AttachTo method.
Make sure that the System.Data.Entity assembly has been referenced in your project, especially if you're using class library that contains your EDM.
"The oxen are slow, but the earth is patient."
Peter Cong
Member
527 Points
681 Posts
Re: Why my entity does not recognize AttachTo() method?
Dec 20, 2012 12:21 PM|LINK
Hi, Thanks for the help,
I am not sure what do you mean the ObjectContext, from my code you can see that basically, I am using entitydata model in my project.
I get the context of entity data model first and then use it.
This is the example I was followed it. The first example of Retrieve is working fine, but the second one (Delete and Update example) which use AttachTo does not work. Yes, I have System.Entity.Data in my reference. since I am using VS2012, I think all of these reference are automatically included.
<div>http://www.mikeborozdin.com/post/Data-Manipulations-with-Entity-Framework.aspx</div>Chen Yu - MS...
All-Star
21598 Points
2493 Posts
Microsoft
Re: Why my entity does not recognize AttachTo() method?
Dec 26, 2012 08:58 AM|LINK
Hi,
From your error message, it seems that Project1.TestEntities didn't contain 'Attachto' method. Have you tried to use
"context.AttachTo( "Tables", com);" in your code? If so, please try to use this code. It will make sense.
http://blogs.msdn.com/b/alexj/archive/2009/06/19/tip-26-how-to-avoid-database-queries-using-stub-entities.aspx
Thanks.
Feedback to us
Develop and promote your apps in Windows Store