public override void SyncProjectEntities(DataSourceEntity[] entities)
		{
			if (this.Project == null) throw new ApplicationException("Project is null.");
			ArrayList updatedEntities = new ArrayList();
			foreach (DataSourceEntity entity in entities) 
			{
				Type schema = GetEntitySchema(entity);
				Entity orEntity = GetMetadataEntity(entity, true);
				this.RefreshSchemaInfo(schema, orEntity);
				updatedEntities.Add(orEntity);
				if (this.OrmConfiguration.CustomEntityAttributes.Count > 0)
				{
					foreach (NameValuePair att in this.OrmConfiguration.CustomEntityAttributes)
					{
						orEntity.SetAttributeValue(att.Name, att.Value);
					}
				}
				orEntity.OwningMetadataFile.Save();
			}
		}
		private bool DataSourcedEntityExistsInProject(DataSourceEntity table)
		{
			foreach (MetadataFile file in _dataSource.Project.MetadataFiles) 
			{
				foreach (IMetadataEntity entity in file.MetadataEntities) 
				{
					if (entity is Entity &&
						((Entity) entity).DBEntityName == table.Name &&
						((Entity) entity).DataSourceName == _dataSource.Name) 
					{
						return true;
					}
				}
			}
			return false;
		}
		protected string GetEntityFileName(DataSourceEntity entity) 
		{
			string filepart = 
				entity.Namespace.Trim() == "" ? 
				entity.Name : 
				entity.Namespace + "." + entity.Name;
			return Path.Combine(this.Project.GetFullMetadataPath(), filepart + ".xml");
		}
		private Type GetEntitySchema(DataSourceEntity entity)
		{
			Assembly asm = LoadAssembly();
			foreach (Type t in asm.GetTypes())
			{
				if (t.Name == entity.Name && t.Namespace == entity.Namespace)
				{
					return t;
				}
			}
			return null;
		}
		private Entity CreateMetadataFile(DataSourceEntity entity) 
		{
			MetadataFile file = new MetadataFile(this.Project);
			Entity orEntity = new Entity();
			file.MetadataEntities.Add(orEntity);
			file.Save(GetEntityFileName(entity));
			this.Project.MetadataFiles.Add(file);
			return orEntity;
		}
		protected Entity GetMetadataEntity(DataSourceEntity table, bool create) 
		{
			foreach (MetadataFile file in this.Project.MetadataFiles) 
			{
				foreach (IMetadataEntity entity in file.MetadataEntities) 
				{
					if (entity is Entity &&
						((Entity) entity).DBEntityName == table.Name &&
						(((Entity) entity).DataSourceName == this.Name 
						 || file.GetFullPath() == GetEntityFileName(table))) 
					{
						return (Entity) entity;
					}
				}
			}
			if (create)
				return CreateMetadataFile(table);
			else
				return null;
		}
		public abstract void SyncProjectEntities(DataSourceEntity[] entities);
		private TableSchema GetTableSchema(DataSourceEntity entity)
		{
			foreach (TableSchema table in _dbschema.Tables.Values)
			{
				if (table.Name == entity.Name) return table;
			}
			return null;
		}
		internal void AddEntity(DataSourceEntity entity)
		{
			_entities.Add(entity);
		}