示例#1
0
        private void TryErrorsEntityFrameworkGenerator(EntityFrameworkGenerator gen)
        {
            List <string> errors = gen.Errors.ToList();

            if (errors.Count != 0)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < errors.Count; i++)
                {
                    sb.Append(" - ").AppendLine(errors[i]);
                }
                throw new WizardException(string.Format("The Entity Framework generation failed with the following errors:\n\n",
                                                        sb.ToString()));
            }
        }
示例#2
0
        private void AddDataEntityArtifactsToProject(EntityFrameworkGenerator gen, string modelName, VSProject vsProj, MySqlConnection con)
        {
            try
            {
                string modelPath = ProjectPath;

                if (projectType == ProjectWizardType.AspNetMVC)
                {
                    modelPath = Path.Combine(ProjectPath, "Models");
                }

                // Adding references
                AddReferencesEntityFramework(vsProj);
            }
            catch (Exception e)
            {
                throw new WizardException("Failed operation when adding model to project", e);
            }
        }
示例#3
0
        protected void GenerateEntityFrameworkModel(
            Project project, VSProject vsProj, MySqlConnection con, string modelName, List <string> tables, string modelPath)
        {
            string ns = GetCanonicalIdentifier(ProjectNamespace);
            EntityFrameworkGenerator gen = new EntityFrameworkGenerator(
                con, modelName, tables, modelPath, ns, CurrentEntityFrameworkVersion, Language, vsProj, ColumnMappings);

            vsProj = project.Object as VSProject;

            AddDataEntityArtifactsToProject(gen, modelName, vsProj, con);
            if (projectType == ProjectWizardType.WindowsForms)
            {
                SetupConfigFileEntityFramework(vsProj, GetConnectionString(), modelName);
            }
            project.DTE.Solution.SolutionBuild.Build(true);
            gen.Generate();

            if (gen.TablesInModel.Count() > 0)
            {
                TablesIncludedInModel = gen.TablesInModel.ToDictionary <string, string>(p => p);
            }

            TryErrorsEntityFrameworkGenerator(gen);
        }