Search code examples
.netasp.netentity-frameworkdynamic-data

Dynamic Data without both database and model updates


I have come to the conclusion that the very nifty ASP.NET Dynamic Data framework would be even more nifty if one only had to implement model changes from one side, model or DB. Right now, if I add a column or table, I must refresh my EF model, and then the scaffolding does the dirty work.

I would much prefer a mechanism where I can update my EF model, and have changes pushed back to the DB, or update my DB and programmatically update my EF model. Prototyping on site, without Visual Studio, would be amazing. Just add a column and hit the site.

Are there any projects that deal with this? If not, where should I start looking to learn about either or both of the approaches I mention?


Solution

  • If you are working against .NEt 4.0 you should look at Code-Only.

    Not only does it allow you to create your models in code (i.e. without an EDMX) it also allows you to deploy your model to a database, like this:

    using (MyContext ctx = new MyContext())
    {
       if (!ctx.DatabaseExists())
          ctx.CreateDatabase();
       ...
       // normal ef code here...
    }
    

    See this tip for more

    While Code-Only is not shipping as part of .NET 4.0, the functions that support this CreateDatabase scenario are being moved from Code-Only into .NET 4.0.

    That hadn't happened when .NET 4.0 Beta2 shipped, so you have to download the Code-Only bits to get this to work against Beta2.

    But when .NET 4.0 RTMs the CreateDatabase() functions will be in the box.

    Hope this helps

    Alex