HowTo: Enable intellisense for entities and properties

In order to enable entities and properties intellisense you must export your nhibernate configuration. Remember that you can export on any project of your solution, even in a data test project.

Step 1: Add a reference to System.ComponentModel.Composition
2010-08-19_2027.png

Step 2: Add a class with your configuration as follows:

	public class ConfigurationExporter 
	{
		[Export(typeof(Configuration))]	
		public static Configuration Configuration
		{
			get
			{
				var configuration = new Configuration();
				var assemblyWithMappings = typeof(ConfigurationExporter);
				configuration.Properties[Environment.Dialect] = typeof(MsSql2005Dialect).FullName;
				configuration.AddAssembly(assemblyWithMappings.Assembly);
				return configuration;	
			}
		}
	}
Note: if you have a full hibernate.cfg.xml (with the mapping-assembly tag) you don’t need to do anything else, just use “return new Configuration().Configure”.

Last edited Sep 22, 2010 at 11:54 AM by jfromaniello, version 5

Comments

No comments yet.