Procedura: generare il modello a oggetti come file esternoHow to: Generate the Object Model as an External File

In alternativa al mapping basato sugli attributi, è possibile generare il modello a oggetti come file XML esterno usando lo strumento da riga di comando SQLMetal.As an alternative to attribute-based mapping, you can generate your object model as an external XML file by using the SQLMetal command-line tool. Per altre informazioni, vedere SqlMetal.exe (strumento per la generazione del codice).For more information, see SqlMetal.exe (Code Generation Tool). Usando un file di mapping XML esterno, si evita confusione nel codice.By using an external XML mapping file, you reduce clutter in your code. È anche possibile modificare il comportamento modificando il file esterno senza ricompilare i file binari dell'applicazione.You can also change behavior by modifying the external file without recompiling the binaries of your application. Per ulteriori informazioni, vedere Mapping esterno.For more information, see External Mapping.

Nota

Object Relational DesignerObject Relational Designer non supporta la generazione di un file di mapping esterno.The Object Relational DesignerObject Relational Designer does not support generation of an external mapping file.

EsempioExample

Il comando seguente genera un file di mapping esterno dal database di esempio Northwind.The following command generates an external mapping file from the Northwind sample database.

sqlmetal /server:myserver /database:northwind /map:externalfile.xml  

EsempioExample

L'estratto seguente di un file di mapping esterno mostra il mapping per la tabella Customers del database di esempio Northwind.The following excerpt from an external mapping file shows the mapping for the Customers table in the Northwind sample database. Questo estratto viene generato eseguendo SQLMetal con la /Map opzione.This excerpt was generated by executing SQLMetal with the /map option.

<?xml version="1.0" encoding="utf-8"?>  
<Database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="northwnd">  
  <Table Name="Customers">  
    <Type Name=".Customer">  
      <Column Name="CustomerID" Member="CustomerID" Storage="_CustomerID" DbType="NChar(5) NOT NULL" CanBeNull="False" IsPrimaryKey="True" />  
      <Column Name="CompanyName" Member="CompanyName" Storage="_CompanyName" DbType="NVarChar(40) NOT NULL" CanBeNull="False" />  
      <Column Name="ContactName" Member="ContactName" Storage="_ContactName" DbType="NVarChar(30)" />  
      <Column Name="ContactTitle" Member="ContactTitle" Storage="_ContactTitle" DbType="NVarChar(30)" />  
      <Column Name="Address" Member="Address" Storage="_Address" DbType="NVarChar(60)" />  
      <Column Name="City" Member="City" Storage="_City" DbType="NVarChar(15)" />  
      <Column Name="Region" Member="Region" Storage="_Region" DbType="NVarChar(15)" />  
      <Column Name="PostalCode" Member="PostalCode" Storage="_PostalCode" DbType="NVarChar(10)" />  
      <Column Name="Country" Member="Country" Storage="_Country" DbType="NVarChar(15)" />  
      <Column Name="Phone" Member="Phone" Storage="_Phone" DbType="NVarChar(24)" />  
      <Column Name="Fax" Member="Fax" Storage="_Fax" DbType="NVarChar(24)" />  
      <Association Name="FK_CustomerCustomerDemo_Customers" Member="CustomerCustomerDemos" Storage="_CustomerCustomerDemos" ThisKey="CustomerID" OtherTable="CustomerCustomerDemo" OtherKey="CustomerID" DeleteRule="NO ACTION" />  
      <Association Name="FK_Orders_Customers" Member="Orders" Storage="_Orders" ThisKey="CustomerID" OtherTable="Orders" OtherKey="CustomerID" DeleteRule="NO ACTION" />  
    </Type>  
  </Table>  
</Database>  

Vedere ancheSee Also

Creazione del modello a oggettiCreating the Object Model
External Mapping (Mapping esterno)External Mapping
Procedura: Generare il modello a oggetti in Visual Basic o C#How to: Generate the Object Model in Visual Basic or C#