locked
How to generate Entity Model using code? RRS feed

  • Question

  • I have the need to regenerate my Entity Model using code. I don't wan't to go and right click and update model from database every time there is a change.

    So i started looking at EdmGen and EdmGen2

    I use EdmGen2 to pregenerate my Model Views for me:

    using (System.Diagnostics.Process process = new System.Diagnostics.Process())
    {
        process.StartInfo.FileName = @"C:\EdmGen2.exe";
        process.StartInfo.Arguments = @"/ViewGen cs ""C:\Project\EntityFramework\Model\ApplicationEntityModel.edmx""";
        process.StartInfo.WorkingDirectory = @"C:\Project\EntityFramework\Model";
        process.Start();
        process.WaitForExit();
    }
    This works perfectly.

    No i am trying to regenerate my Entity Model:

    using (System.Diagnostics.Process process = new System.Diagnostics.Process())
    {
        process.StartInfo.FileName = @"C:\EdmGen2.exe";
        process.StartInfo.Arguments = String.Format(@"/ModelGen ""{0}"" ""System.Data.SqlClient"" ""ApplicationEntityModel""", ConnectionString);
        process.StartInfo.WorkingDirectory = @"C:\Project\EntityFramework\Model";
        process.Start();
        process.WaitForExit();
    }
    This only generates the .edmx file. Can't specify namespaces so this is not working for me.

    Is there any tool or template that i can use to completely regenerate my Entity Model', this includes the.edmxanddesigner.cs` using just c# code?
    • Moved by Bob Shen Monday, August 27, 2012 5:59 AM (From:Visual C# General)
    Friday, August 24, 2012 8:19 AM

Answers

  • EdmGen is the only tool to generate edmx file now, you can submit your good suggestion here.


    Go go Doraemon!

    • Proposed as answer by Allen_MSDN Wednesday, August 29, 2012 1:25 AM
    • Marked as answer by Allen_MSDN Thursday, August 30, 2012 5:22 AM
    Monday, August 27, 2012 6:23 AM