Пример #1
0
        /// <summary>
        /// Generates the entity framework model.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="vsProj">The Visual Studio project object.</param>
        /// <param name="connection">The MySql connection.</param>
        /// <param name="modelName">Name of the "edmx" model.</param>
        /// <param name="tables">The tables.</param>
        /// <param name="modelPath">The model path.</param>
        /// <param name="currentEntityFrameworkVersion">The current entity framework version.</param>
        /// <param name="language">The language generator (C# or VB.NET).</param>
        /// <param name="columnMappings">The column mappings.</param>
        /// <param name="tablesIncludedInModel">The tables included in model.</param>
        internal static void GenerateEntityFrameworkModel(Project project, VSProject vsProj, MySqlConnection connection, string modelName, List <string> tables, string modelPath,
                                                          string currentEntityFrameworkVersion, LanguageGenerator language, Dictionary <string, Dictionary <string, ColumnValidation> > columnMappings, ref Dictionary <string, string> tablesIncludedInModel)
        {
            if (project != null)
            {
                string projectNamespace = project.Properties.Item("DefaultNamespace").Value.ToString();
                string ns = GetCanonicalIdentifier(projectNamespace);
                EntityFrameworkGenerator gen = new EntityFrameworkGenerator(connection, modelName, tables, modelPath, ns, currentEntityFrameworkVersion, language, vsProj, columnMappings);
                vsProj = project.Object as VSProject;
                project.DTE.Solution.SolutionBuild.Build(true);
                string projectPath = Path.GetDirectoryName(project.FullName);
                gen.GenerateItemTemplates(projectPath, modelName);
                if (gen.TablesInModel.Count() > 0)
                {
                    tablesIncludedInModel = gen.TablesInModel.ToDictionary <string, string>(p => p);
                }

                TryErrorsEntityFrameworkGenerator(gen);
            }
        }