// Validates the model returned by the Visual Studio dialog. // We always force a Visual Studio build so we have a model // that we can use with the Entity Framework. private void Validate() { CodeType modelType = _codeGeneratorViewModel.ModelType.CodeType; ModelType dbContextType = _codeGeneratorViewModel.DbContextModelType; string dbContextTypeName = (dbContextType != null) ? dbContextType.TypeName : null; if (modelType == null) { throw new InvalidOperationException(Resources.WebFormsScaffolder_SelectModelType); } if (dbContextType == null || String.IsNullOrEmpty(dbContextTypeName)) { throw new InvalidOperationException(Resources.WebFormsScaffolder_SelectDbContextType); } // always force the project to build so we have a compiled // model that we can use with the Entity Framework var visualStudioUtils = new VisualStudioUtils(); visualStudioUtils.BuildProject(Context.ActiveProject); Type reflectedModelType = GetReflectionType(modelType.FullName); if (reflectedModelType == null) { throw new InvalidOperationException(Resources.WebFormsScaffolder_ProjectNotBuilt); } }
// Validates the model returned by the Visual Studio dialog. // We always force a Visual Studio build so we have a model private void Validate() { CodeType modelType = _moduleViewModel.ModelType.CodeType; if (modelType == null) { throw new InvalidOperationException("请选择一个有效的实体类。"); } var visualStudioUtils = new VisualStudioUtils(); visualStudioUtils.BuildProject(Context.ActiveProject); Type reflectedModelType = GetReflectionType(modelType.FullName); if (reflectedModelType == null) { throw new InvalidOperationException("不能加载的实体类型。如果项目没有编译,请编译后重试。"); } }