views:

198

answers:

3

Im trying to get the most basic of examples to run in FnH. I started with the Examples.FirstProject. However, I did not use the SQL lite configuration. Instead, I set the configuration to SQL2005 and created the tables as was diagramed in the example.

When stepping through the code, there appears to be no problems when creating the session factory. I do receive an error however when the code reaches the "transaction.commit" line. The error reads:

Could not insert collection: [Examples.FirstProject.Entities.Store.Products#5][SQL:SQL not available]

Im wondering if there was an issue with the way the tables were created in SQL Server. The IDs were "int" type and the names and such were "varchar(50)." I set the PK of Store, Product, and Employee to its respective ID field. I also made the ID increment automatically by 1 (IdentitySpecification column property in SQL Server). StoreProduct is the many-to-many and is also there per the diagram.

Any help would be appreciated. Thanks.

+1  A: 

Have you modified the sample in any way other than changing the database provide? Have you been able to save any entities from the sample (ie if you remove the Products code and just save the Store)?

I developed this sample against SQLExpress, so I would imagine there wouldn't be any incompatibilities with SQL 2005.

Also, this question would probably be better be suited to the Fluent NHibernate mailing list, as Stack Overflow isn't great for these kind-of investigatory postings.

James Gregory
A: 

Thank you James. I'll look at using Fluent NHibernate mailing list. As a solution to my issue, I did simplify the example a bit and found that rebuilding the tables helped. In the previous attempt I built the tables in the Database diagram tool. That is where I think something was a little off. Just now I rebuilt them using the menus and still made the foreign key connections with the Database Diagram section. Worked like a charm. Thanks again and keep up the good work with FnH.

A: 

First thing to check: Are you sure that you have really created a correct table in SQL server, and that the schema is correct? You can verify this by using SQL Express management studio to view the sql database.

Ngu Soon Hui