OK let me get this right. What I want to do is create code whereby when I click a button the code will automatically check the current database against the schema and if there is a difference update the database to match the schema. Now the way I am attempting this is as following
1) I have a class library project called DateModel. It contains all the table classes that I generated via reverse mapping.
2) I have a web application which references the project that has the DataModel. This project as been ORM enabled. I have now basically used the following code to try and update my database from the schema (currently trying to print the sql)
| Dim db = ObjectScopeProvider1.Database |
| If db.GetSchemaHandler.DatabaseExists = False Then |
| db.GetSchemaHandler.CreateDatabase() |
| End If |
| Dim script = db.GetSchemaHandler.CreateUpdateDDLScript(Nothing) |
| Response.Write(script) |
The script is always an empty string, even though I make the effort to delete tables, add new fields and basically make sure the db is very different to the schema. Is there something I am missing here? You mentioned setting the property to UpdateDatabase. Is this the property for the DataModel project (based on my setup). If so it says that it will update my database on compile however I want to update my database at runtime.