Now it's time to get to the real meat! We have spent the last four chapters "getting ready", and now we will actually create some data. Just like before, if you run into trouble (doesn't work like the walkthrough), see the troubleshooting section at the end of this Time for action.
Open the
Program.cs
orModule1.vb
from the last Time for action, and scroll to the line that sayscfg.AddAssembly(typeof(Address).Assembly)
. On a new line, add the following code:ISessionFactory sessionFactory = cfg.BuildSessionFactory();
In VB.NET, use this code:
Dim sessionFactory As ISessionFactory = cfg.BuildSessionFactory()
Press F5 or Debug | Start Debugging and test your project. If everything goes well, once again a command prompt window will pop up and then go away. If you happen to get an InvalidProxyTypeException, as shown in the following screenshot, it usually has to do with a property not being marked as "virtual" or "Overridable".