i am try to add a new table in a NopModel.edmx file and create new page and add its .cs file in business logic all work perfectly but its give error "Mapping and metadata information could not be found for EntityType 'NopSolutions.NopCommerce.BusinessLogic.Workshops.Workshop'. "
here Workshop is table which was i add in database and nopmodel.edmx file. error is come at runtime at the build process done sucessfully.
i think problem with entity it was not find the "Workshop" entity in edmx file i was also update edmx file and add workshop entity.
Errors of type Mapping and metadata information could not be found for EntityType can be caused by a number of things but the most common I find with nop are where the property names in the associated class (POCO Class) are not exactly the same case as the property in the NopModel.edmx file.
ProductID / ProductId will produce this error.
Check them in Workshop.cs (think this is your class?)
other causes maybe;-
* Misspelled properties (case-sensitive!) * Properties missing in the POCO class * Type mismatches between the POCO and entity-type (e.g., int instead of long) * Enums in the POCO (EF doesn't support enums right now as I understand)
I would also watch for nullable types in the db and make the POCO class have nullable types (not required for string).
The link above does not work exactly with version 1.9 http://blogs.planetcloud.co.uk/mygreatdiscovery/post/How-to-extend-nopCommerce.aspx
not even close to a good example for v1.9 and lends itself to confusion and total crash for people that don't have a clue as to how EF works along with the fact that the POCO T4 auto generation has been removed and then to top it off that example is for v1.8 I am guessing from reading on these forums for days.
Something about the link missing the examples for the interfaces and such for version 1.9
Can someone point to a simple clear example for v1.9 to add a new attribute to any table or can some point to a clear example how to add a new table to the edmx
I make it through most of the example in the link but crash and burn when it came to the part of adding the manager on this line var db = no ObjectContextHelper.CurrentObjectContext;
It does like at all the ObjectContextHelper.
I am new to ef and POCO and again to top it off nop hand crafted the .tt files and as such even examples found on the web can not help with this because nop wrote allot from scratch. I have been reading for a week now trying to figure this out and to no avail i am still totally lost but have learned a great deal and found many exciting approaches nop took but again I am totally lost.
thanks for everyone involved this is a great product and I am able to accomplish allot of custom development and i understand a great deal about certain classes and such, but again my skills with EF POCO hand written interfaces and such are lacking very much
I finally got it working with some codesnippets found on this forum:
Hope you can use my code below. I have added a table "MOD_License" and all is working. You can use the blogpost for adding the table in the .emdx and use the code below for the rest.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Objects; using NopSolutions.NopCommerce.BusinessLogic.MOD; using NopSolutions.NopCommerce.BusinessLogic.Data; using NopSolutions.NopCommerce.BusinessLogic.Infrastructure;
publicstaticvoid Delete_LicenseById(int LicenseId) { var license = GetMOD_LicenseById(LicenseId); if (license == null) return;
var db = IoC.Resolve<NopObjectContext>(); if (!db.IsAttached(license)) db.MOD_Licenses.Attach(license); db.DeleteObject(license); db.SaveChanges(); }
publicstaticvoid Save(MOD_License license) { var db = IoC.Resolve<NopObjectContext>();
if (license.LicenseID == 0) { // new record db.MOD_Licenses.AddObject(license); } else { // existing record if (!db.IsAttached(license)) db.MOD_Licenses.Attach(license); }