I get the following error:
System.InvalidOperationException is not handled Message = The judge type is not assigned to the EdmEntityTypeAttribute attribute, but is contained in the assembly associated with EdmSchemaAttribute. POCO entities that do not use EdmEntityTypeAttribute cannot be contained in the same assembly as non-POCO entities that use EdmEntityTypeAttribute.
Source = EntityFramework StackTrace: in System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType (Type object type) in System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType (Type EntityType)
public class GenericRepository<TEntity> where TEntity : class { internal z context; internal DbSet<TEntity> dbSet; public GenericRepository(z context) { this.context = context; this.dbSet = context.Set<TEntity>(); } public GenericRepository() { this.context = new z(); this.dbSet = context.Set<TEntity>(); } public virtual IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "") { IQueryable<TEntity> query = dbSet; if (filter != null) { query = query.Where(filter); } foreach (var includeProperty in includeProperties.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { query = query.Include(includeProperty); } if (orderBy != null) { return orderBy(query).ToList(); } else { return query.ToList(); //Getting error here!! } } public virtual TEntity GetByID(object id) { return dbSet.Find(id); } public virtual void Insert(TEntity entity) { dbSet.Add(entity); } public virtual void Delete(object id) { TEntity entityToDelete = dbSet.Find(id); Delete(entityToDelete); } public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); } public virtual void Update(TEntity entityToUpdate) { dbSet.Attach(entityToUpdate); context.Entry(entityToUpdate).State = EntityState.Modified; } public virtual void Save() { context.SaveChanges(); } }
The weird part: the judge is attributed to the EdmEntityTypeAttribute attribute because it is automatically created as part of the DbContext T-4 jazz.
/// <summary> /// No Metadata Documentation available. /// </summary> [EdmEntityTypeAttribute(NamespaceName="standaloneModel", Name="Judge")] [Serializable()] [DataContractAttribute(IsReference=true)] public partial class Judge : EntityObject {
At some point, I had a different class judge in a different assembly, but since then I renamed it. I tried to clean both projects. There should be no other class of judges than EF.
So, I canβt understand where this other class of judge comes from
thanks
c # repository entity-framework entity-framework-4
bulltorious
source share