public static void AddDataAnnotations(this IDotNetClassDefinition classDefinition, IView view, EntityFrameworkCoreProject project)
        {
            classDefinition.Attributes.Add(new MetadataAttribute("Table", string.Format("\"{0}\"", view.Name))
            {
                Sets = new List <MetadataAttributeSet>
                {
                    new MetadataAttributeSet("Schema", string.Format("\"{0}\"", view.Schema))
                }
            });

            var primaryKeys = project.Database.Tables.Where(item => item.PrimaryKey != null).Select(item => item.PrimaryKey?.GetColumns(item).Select(c => c.Name).First()).ToList();

            var result = view.Columns.Where(item => primaryKeys.Contains(item.Name)).ToList();

            for (var i = 0; i < view.Columns.Count; i++)
            {
                var column = view.Columns[i];

                foreach (var property in classDefinition.Properties)
                {
                    if (column.GetPropertyName() == property.Name)
                    {
                        property.Attributes.Add(new MetadataAttribute("Column", string.Format("\"{0}\"", column.Name))
                        {
                            Sets = new List <MetadataAttributeSet>
                            {
                                new MetadataAttributeSet("Order", (i + 1).ToString())
                            }
                        });

                        if (!column.Nullable && primaryKeys.Contains(column.Name))
                        {
                            property.Attributes.Add(new MetadataAttribute("Key"));
                        }

                        if (!column.Nullable)
                        {
                            property.Attributes.Add(new MetadataAttribute("Required"));
                        }
                    }
                }
            }
        }
 public static string GetDataLayerConfigurationsDirectory(this EntityFrameworkCoreProject project)
 => Path.Combine(project.OutputDirectory, project.Namespaces.DataLayer, project.Namespaces.Configurations);
 public static string GetDataLayerRepositoriesDirectory(this EntityFrameworkCoreProject project)
 => Path.Combine(project.OutputDirectory, project.Namespaces.DataLayer, project.Namespaces.Repositories);
 public static string GetEntityLayerDirectory(this EntityFrameworkCoreProject project)
 => Path.Combine(project.OutputDirectory, project.Namespaces.EntityLayer);
 public static string GetDataLayerRepositoriesNamespace(this EntityFrameworkCoreProject project)
 => string.Join(".", namingConvention.GetClassName(project.Name), project.Namespaces.DataLayer, project.Namespaces.Repositories);
 public static string GetDataLayerNamespace(this EntityFrameworkCoreProject project)
 => string.Join(".", new string[] { namingConvention.GetClassName(project.Name), project.Namespaces.DataLayer });
 public static string GetEntityLayerNamespace(this EntityFrameworkCoreProject project, string ns)
 => string.IsNullOrEmpty(ns) ? GetEntityLayerNamespace(project) : string.Join(".", project.Name, project.Namespaces.EntityLayer, ns);
 public static string GetEntityLayerNamespace(this EntityFrameworkCoreProject project)
 => string.Join(".", namingConvention.GetClassName(project.Name), namingConvention.GetNamespace(project.Namespaces.EntityLayer));