#Usage:
-
Create a separate Model library with auto incrementing build numbers. By setting the assembly version to a wildcard:
[assembly: AssemblyVersion("1.0.*")] -
Ensure your model tables are contained in a suitably
named public static classi.e.public static class Model { public class Article : IHasId<int> { -
Add the
TableCreationOrderAttributeto the model project, outside thestatic class- So it's not considered part of it! -
Decorate your model with the
TableCreationOrderi.e.[TableCreationOrder(3)] public class Article : IHasId<int> { ... -
Add the
CheckDatabaseModelmethod to your project. (If you have added it to a utility library just reference it!) -
Add a reference to the Model assembly in your project. And call the check on the type of the model assembly:
CheckDatabaseModel(typeof(Model)); -
Ensure your application has an
app.configorweb.configas appropriate. It can be empty, the code will auto-initialise it. -
Relax, your project will now pick up changes to your model automatically when it runs, and your database will be updated!
CheckDatabaseModel required to reference:
- using System.Reflection;
- using System.Configuration;