IT:AD:Code First:Deployment

Warning: Code first has no change tracking story. The process to follow is:

* Read this – might be useful: http://weblogs.asp.net/jgalloway/archive/2011/02/24/generating-ef-code-first-model-classes-from-an-existing-database.aspx

Excellent in depth analysis of the steps happening under the covers: * http://blog.oneunicorn.com/2011/04/15/code-first-inside-dbcontext-initialization/

Astoundingly, one can build everything via CodeFirst – and then dump it to a SQL script to be optimized as needed:

using (var context = new Context())
{
  string script = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript();
}

And holy catnip, one can get the edmnx as well:

using (var context = new Context())
{
  XmlWriterSettings settings = new XmlWriterSettings();
  settings.Indent = true;
 
  using (XmlWriter writer = XmlWriter.Create(@"Model.edmx", settings))
  {
    EdmxWriter.WriteEdmx(context, writer);
  }                            
}
  • /home/skysigal/public_html/data/pages/it/ad/code_first/deployment.txt
  • Last modified: 2023/11/04 03:22
  • by 127.0.0.1