src/Shared/EntityFramework.SqlServerCompact/SqlDdlBuilder.cs
// <summary>
// Function for generating create table statements.
// </summary>
Function for generating create table statements.
Function for generating create table statements .
private void AppendCreateTable(EntitySet entitySet)
        {
            var objectBuilder = new StringBuilder();
            if (entitySet.MetadataProperties["DefiningQuery"].Value != null)
            {
                ignoredEntitySets.Add(entitySet);
                objectBuilder.Append(" -- Ignoring entity set with defining query: "); 
                AppendIdentifierEscapeNewLine(objectBuilder, GetTableName(entitySet));
                objectBuilder.AppendLine();
                ignoredObjects.Add(objectBuilder.ToString());
            }
            else
            {
                objectBuilder.Append("CREATE TABLE ");
                AppendIdentifier(objectBuilder, GetTableName(entitySet));
                objectBuilder.Append(" (");
                objectBuilder.AppendLine();
                foreach (var column in entitySet.ElementType.Properties)
                {
                    objectBuilder.Append("    ");
                    AppendIdentifier(objectBuilder, column.Name);
                    objectBuilder.Append(" ");
                    AppendType(objectBuilder, column);
                    objectBuilder.Append(",");
                    objectBuilder.AppendLine();
                }
                if (entitySet.ElementType.KeyMembers.Count > 0)
                {
                    objectBuilder.Append("    PRIMARY KEY (");
                    var first = true;
                    foreach (var keyMember in entitySet.ElementType.KeyMembers)
                    {
                        if (IsServerGeneratedGuid(keyMember))
                        {
                            throw ADP1.ServerGeneratedGuidKeyNotSupportedException(keyMember.Name);
                        }
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            objectBuilder.Append(",");
                        }
                        AppendIdentifier(objectBuilder, keyMember.Name);
                    }
                    objectBuilder.Append(")");
                    objectBuilder.AppendLine();
                }
                objectBuilder.Append(");");
                objectBuilder.AppendLine();
                objects.Add(objectBuilder.ToString());
            }
        }
private void AppendCreateTable ( EntitySet entitySet ) { var objectBuilder = new StringBuilder ( ) ; if ( entitySet . MetadataProperties [ " " ] . Value != null ) { ignoredEntitySets . Add ( entitySet ) ; objectBuilder . Append ( " " ) ; AppendIdentifierEscapeNewLine ( objectBuilder , GetTableName ( entitySet ) ) ; objectBuilder . AppendLine ( ) ; ignoredObjects . Add ( objectBuilder . ToString ( ) ) ; } else { objectBuilder . Append ( " " ) ; AppendIdentifier ( objectBuilder , GetTableName ( entitySet ) ) ; objectBuilder . Append ( " " ) ; objectBuilder . AppendLine ( ) ; foreach ( var column in entitySet . ElementType . Properties ) { objectBuilder . Append ( " " ) ; AppendIdentifier ( objectBuilder , column . Name ) ; objectBuilder . Append ( " " ) ; AppendType ( objectBuilder , column ) ; objectBuilder . Append ( " " ) ; objectBuilder . AppendLine ( ) ; } if ( entitySet . ElementType . KeyMembers . Count > 0 ) { objectBuilder . Append ( " " ) ; var first = true ; foreach ( var keyMember in entitySet . ElementType . KeyMembers ) { if ( IsServerGeneratedGuid ( keyMember ) ) { throw ADP1 . ServerGeneratedGuidKeyNotSupportedException ( keyMember . Name ) ; } if ( first ) { first = false ; } else { objectBuilder . Append ( " " ) ; } AppendIdentifier ( objectBuilder , keyMember . Name ) ; } objectBuilder . Append ( " " ) ; objectBuilder . AppendLine ( ) ; } objectBuilder . Append ( " " ) ; objectBuilder . AppendLine ( ) ; objects . Add ( objectBuilder . ToString ( ) ) ; } }
Function for generating create table statements.
Function for generating create table statements .
// Ignore the set if it is a defining query. // Adding a comment. // Column information. // Primary key information. // CodePlex issue: http://entityframework.codeplex.com/workitem/437 // Throw an exception if key member is of server generated guid type. // This is because DML operations won't succeed if key column is of server generated with GUID type.
entitySet
EntitySet