|
Post by Zaid Faridi on Jan 3, 2015 19:10:57 GMT
db.Products.Find(id) and db.Products.Add() not working.The error message says that Find() and Add() are not defined. Please help.
|
|
zedf
New Member
Posts: 1
|
Post by zedf on Jan 4, 2015 13:14:03 GMT
Hi i am building a webshop using VS 2010 and sql server management studios. It is the exact code i saw in a tutorial but the Find() and Add() functions are giving errors. Please help.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using GarageDBModel; /// <summary> /// Summary description for ProductModel /// </summary> public class ProductModel { public string InsertProduct(Product product) { try { GarageDBEntities db = new GarageDBEntities(); db.Products.Add(product); db.SaveChanges(); return product.Name + "was succesfuly Inserted"; } catch (Exception e) { return "Error:" + e; } } public string UpdateProduct(int id, Product product) { try { GarageDBEntities db = new GarageDBEntities(); Product p = db.Products.Find(id); } catch(Exception e) { return "Error:" + e; } }
Collapse | Copy Code Error 4 'System.Data.Objects.ObjectSet<GarageDBModel.Product>' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Data.Objects.ObjectSet<GarageDBModel.Product>' could be found (are you missing a using directive or an assembly reference?) C:\Users\Zaid\Documents\Visual Studio 2010\WebSites\Garagemanager\App_Code\Models\ProductModel.cs 18 25 C:\...\Garagemanager\ Collapse | Copy Code Error 5 'System.Data.Objects.ObjectSet<GarageDBModel.Product>' does not contain a definition for 'Find' and no extension method 'Find' accepting a first argument of type 'System.Data.Objects.ObjectSet<GarageDBModel.Product>' could be found (are you missing a using directive or an assembly reference?) C:\Users\Zaid\Documents\Visual Studio 2010\WebSites\Garagemanager\App_Code\Models\ProductModel.cs 34 37 C:\...\Garagemanager\
|
|
|
Post by Sagher Ahmed on Jan 23, 2015 11:16:20 GMT
Sir, your videos are very good and it is the best training. i'm using visual studio 2013 and have problem i just stuck in private void GetImages() funcation, first is, i not found Directory (Keyword) and ArrayList..... i thought in 2013 have a new keywords. sir if you have any new funcation to get all images from the server.mappath.... please sir give me....
thanks in advance sagheer ahmed sagheer.2000@gmail.com
|
|
|
Post by Jhon on Feb 22, 2015 18:34:56 GMT
|
|
|
Post by Jhon on Feb 22, 2015 18:39:14 GMT
Hi! While inserting the Category Entities, it shows validation failed and could not enter the entity. Have any Idea, why this happen? And ddlImage and other ddl are not recognized. What can i do for this? I will be grate full for the help. Thank YOU.
|
|
|
Post by adam on Mar 15, 2015 20:44:48 GMT
In regards to your 3rd part video is it possible to do this in VS2010?
|
|
|
Post by Tim on Apr 3, 2015 3:25:53 GMT
Hi This error came up can you help? Error:System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at ProductModel.InsertProduct(Product product) in c:\Users\Owner\Documents\Bulding e-coomerce\projectFinal\App_Code\Models\ProductModel.cs:line 20
|
|
|
Post by dhanesh on Jul 25, 2015 18:41:44 GMT
Hello sir first of all many thanks for your videos, its real help full. in the updateproduct method i cant access find method..any help much appreciated.
|
|
|
Post by Jose on Aug 1, 2015 7:13:14 GMT
HI! i am having this problem when i try to introduce a product to the database, any ideas why is this happens? thanks.
"Error;System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.InvalidOperationException: A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'. at System.Data.Entity.Core.Mapping.Update.Internal.UpdateCompiler.BuildSetClauses(DbExpressionBinding target, PropagatorResult row, PropagatorResult originalRow, TableChangeProcessor processor, Boolean insertMode, Dictionary`2& outputIdentifiers, DbExpression& returning, Boolean& rowMustBeTouched) at System.Data.Entity.Core.Mapping.Update.Internal.UpdateCompiler.BuildInsertCommand(PropagatorResult newRow, TableChangeProcessor processor) at System.Data.Entity.Core.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler) --- End of inner exception stack trace --- at System.Data.Entity.Core.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler) at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.d__a.MoveNext() at System.Linq.Enumerable.d__71`1.MoveNext() at System.Data.Entity.Core.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator) at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.ProduceCommands() at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.b__2(UpdateTranslator ut) at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction) at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update() at System.Data.Entity.Core.Objects.ObjectContext.b__35() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.b__27() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation) at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction) at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Entity.Internal.InternalContext.SaveChanges() --- End of inner exception stack trace --- at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at ProductModel.InsertProduct(Product product) in c:\Users\JoséPablo\Documents\OnlineShop\App_Code\Models\ProductModel.cs:line 18"
|
|
|
Post by Ahamed Kabeer on Sept 8, 2015 7:30:58 GMT
I'm receiving this below error pls help me out on resolving this
Name
ErrorSystem.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Cart'. Previously found CLR type 'Cart', newly found CLR type 'JakShopDBModel.Cart'. The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Product'. Previously found CLR type 'Product', newly found CLR type 'JakShopDBModel.Product'. The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'ProductType'. Previously found CLR type 'ProductType', newly found CLR type 'JakShopDBModel.ProductType'. at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action`1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly) at System.Data.Entity.Core.Metadata.Edm.MetadataOptimization.TryUpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.TryUpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) at System.Data.Entity.DbSet`1.Add(TEntity entity) at ProductTypeModel.InsertProductType(ProductType productType) in c:\Users\sbah\Documents\Visual Studio 2012\WebSites\JakShop\App_Code\Models\ProductTypeModel.cs:line 16
|
|
|
Post by rob on Jan 17, 2016 16:53:41 GMT
Error 1 'ASP.pages_managment_managmentproducts_aspx' does not contain a definition for 'ddllmage_SelectedIndexChanged' and no extension method 'ddllmage_SelectedIndexChanged' accepting a first argument of type 'ASP.pages_managment_managmentproducts_aspx' could be found (are you missing a using directive or an assembly reference?) C:\Users\pc\Documents\Visual Studio 2013\WebSites\uppercrust\Pages\Managment\ManagmentProducts.aspx 26
|
|
|
Post by Help, pls on Apr 9, 2016 13:55:56 GMT
No result returns when clicking submit. What should I do, please help me.
|
|
|
Post by Reem on May 15, 2016 18:48:00 GMT
Hi, Thank you so much for creating those amazing tutorials it really helps me. I am facing a problem i followed all the steps for the first model Insert, when i ran the program to test it it gave me an error
"""" Error: System.Data.Entity.Core.MappingException: The type 'Edm.Int32' of the member 'Price' in the conceptual side type 'ShoesDBModel.Product' does not match with the type 'System.Double' of the member 'Price' on the object side type 'Product'. at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.ValidateMembersMatch(EdmMember edmMember, EdmMember objectMember) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadEntityTypeOrComplexTypeMapping(ObjectTypeMapping objectMapping, EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadObjectMapping(EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadTypeMapping(EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadAssociationTypeMapping(ObjectTypeMapping objectMapping, EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadObjectMapping(EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadTypeMapping(EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadEntityTypeOrComplexTypeMapping(ObjectTypeMapping objectMapping, EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadObjectMapping(EdmType edmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection, Dictionary`2 typeMappings) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.LoadObjectMapping(EdmType cdmType, EdmType objectType, DefaultObjectMappingItemCollection ocItemCollection) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.GetDefaultMapping(EdmType cdmType, EdmType clrType) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.TryGetMap(String identity, DataSpace typeSpace, Boolean ignoreCase, MappingBase& map) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.TryGetMap(String identity, DataSpace typeSpace, MappingBase& map) at System.Data.Entity.Core.Mapping.DefaultObjectMappingItemCollection.TryGetMap(GlobalItem item, MappingBase& map) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.TryGetMap(GlobalItem item, DataSpace dataSpace, MappingBase& map) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.TryGetEdmSpaceType[T](T objectSpaceType, T& edmSpaceType) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetEdmSpaceType[T](T objectSpaceType) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetEdmSpaceType(StructuralType objectSpaceType) at System.Data.Entity.Core.Metadata.Edm.MetadataOptimization.UpdateEntitySetMappings() at System.Data.Entity.Core.Metadata.Edm.MetadataOptimization.TryUpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.TryUpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) at System.Data.Entity.DbSet`1.Add(TEntity entity) at ProductTypeModel.InsertProductType(ProductType productType) in c:\Users\reemoh\Documents\Visual Studio 2015\WebSites\WebSite2\App_Code\Models\ProductTypeModel.cs:line 16
""""
I do not know what to do i doubled checked what i have wrote, I could not find any errors in my program ? Please help me.
Thank you
|
|
|
Post by @Rajat on Aug 27, 2016 6:46:58 GMT
Sir, I am following your videos to build my own project. It's too good to learn new things. Thanks a lot for that. Anyways, sir I made a mistake during my database design phase. In the 'ProductTypes' table I declare the 'Name' column as VARBINARY(50) datatype.During the design of the 'ManageProductTypes.aspx' page I'm getting an errer i.e. private ProductType createProductType() { ProductType p = new ProductType(); p.Name = txtName.Text; // Error: Can't implicitly convert type 'string' to 'Byte'
return p; } After that, to resolve the error I wrote the following SQL command in SQL Server 2008: ALTER TABLE [dbo].[ProductTypes] ALTER COLUMN Name varchar(50) NOT NULL;Commands executed successfully. But still I'm getting the same error on my 'ManageProductTypes.aspx' page. Sir, I need your help regarding this matter. Thank You in advance,
|
|
|
Post by Dev on Dec 23, 2016 4:28:10 GMT
Please Help me on this section.....
|
|