Пример #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);
        }