Beispiel #1
0
        // Internal for testing
        protected internal virtual string GetNamespace(
            [CanBeNull] Migration lastMigration,
            [NotNull] string rootNamespace,
            [NotNull] Type contextType)
        {
            Check.NotEmpty(rootNamespace, "rootNamespace");
            Check.NotNull(contextType, "contextType");

            if (lastMigration != null)
            {
                return(lastMigration.GetType().Namespace);
            }

            var @namespace = rootNamespace + ".Migrations";

            var existingMigrations =
                from t in MigrationAssembly.GetMigrationTypes(MigrationAssembly.Assembly)
                where t.Namespace == @namespace && MigrationAssembly.TryGetContextType(t) != contextType
                select t;

            if (existingMigrations.Any())
            {
                return(@namespace + "." + contextType.Name);
            }

            return(@namespace);
        }
Beispiel #2
0
 public virtual IEnumerable <Type> GetContextTypes() =>
 ContextTool.GetContextTypes(_assembly)
 .Concat(
     MigrationAssembly.GetMigrationTypes(_assembly)
     .Select(MigrationAssembly.TryGetContextType)
     .Where(t => t != null))
 .Distinct();
Beispiel #3
0
 private IEnumerable <Type> GetMigrationTypes()
 {
     return(MigrationAssembly.GetMigrationTypes(_assembly));
 }