2010-11-05 21 views
2

J'essaie d'utiliser migratordotnet pour la base de données existante. Ma base de données compte environ 100 tables et j'essaie de générer une migration initiale.Migratordotnet créant la migration initiale

J'ai essayé d'utiliser

C:\migrations>Migrator.Console.exe SqlServer "Data Source=.\sqlexpress;Initial Catalog=my_database;Integrated Security = True;" MigracijeBaze.dll -dump InitialMigration.cs 

Unfortinutely, la migration a généré chaque colonne avec typeof (string). Les colonnes Int, DateTime, Decimal sont converties en chaîne. Par exemple, pour la table Godine

CREATE TABLE [dbo].[Godine](
    [ID] [int] IDENTITY(1,1) NOT NULL, 
    [FirmaID] [nvarchar](2) NOT NULL, 
    [Godina] [int] NOT NULL, 
    [BazaSifri] [nvarchar](50) NOT NULL, 
    [BazaPodataka] [nvarchar](50) NOT NULL, 
CONSTRAINT [PK_Godine] PRIMARY KEY CLUSTERED 
(
    [ID] ASC 
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 
) ON [PRIMARY] 

est généré la migration

Database.AddTable("Godine", 
    new Column("ID", typeof(String)), 
    new Column("FirmaID", typeof(String)), 
    new Column("Godina", typeof(String)), 
    new Column("BazaSifri", typeof(String)), 
    new Column("BazaPodataka", typeof(String)), 
); 

Est-ce que je fais quelque chose de mal? Quelles sont les meilleures pratiques pour effectuer des migrations initiales?

Répondre

2

J'ai trouvé la réponse. J'ai téléchargé le code source et utilisé le débogueur. Il semble que l'option de vidage n'est pas complètement implémentée.

public virtual Column[] GetColumns(string table) 
{ 
    List<Column> columns = new List<Column>(); 
    using (
     IDataReader reader = 
      ExecuteQuery(
       String.Format("select COLUMN_NAME, IS_NULLABLE from information_schema.columns where table_name = '{0}'", table))) 
    { 
     while (reader.Read()) 
     { 
      Column column = new Column(reader.GetString(0), DbType.String); 
      string nullableStr = reader.GetString(1); 
      bool isNullable = nullableStr == "YES"; 
      column.ColumnProperty |= isNullable ? ColumnProperty.Null : ColumnProperty.NotNull; 

      columns.Add(column); 
     } 
    } 

    return columns.ToArray(); 
} 

Le type de base de données est codé en dur. Je vais juste appeler le script SQL pour ma première migration. Problème connexe: on the issue tracker