locked
dbml to db definition (Script) RRS feed

  • Question

  • User2048898515 posted

    Hi,

    I have a .dbml file. It has table definitions. I want to get the DB definitions for the objects present in dbml file.

    ie. i need  "create table" scripts from the dbml file. How i can get it?

    Monday, November 13, 2017 1:05 PM

All replies

  • User-1838255255 posted

    Hi nambir,

    According to your description, I think you want to get the table definitions from the DBML file, but i notice that the DBML file is XML file, if you wnat to read the table definitions from this XML. Like https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/linq/code-generation-in-linq-to-sql provide DBML file, if you want to get the following string:

    <Table Name="Customers">  
        <Type Name="Customer">  
          <Column Name="CustomerID" Type="System.String" DbType="NChar(5) NOT NULL" IsPrimaryKey="True" CanBeNull="False" />  
          <Column Name="CompanyName" Type="System.String" DbType="NVarChar(40) NOT NULL" CanBeNull="False" />  
          <Column Name="ContactName" Type="System.String" DbType="NVarChar(30)" CanBeNull="True" />  
          <Column Name="ContactTitle" Type="System.String" DbType="NVarChar(30)" CanBeNull="True" />  
          <Column Name="Address" Type="System.String" DbType="NVarChar(60)" CanBeNull="True" />  
          <Column Name="City" Type="System.String" DbType="NVarChar(15)" CanBeNull="True" />  
          <Column Name="Region" Type="System.String" DbType="NVarChar(15)" CanBeNull="True" />  
          <Column Name="PostalCode" Type="System.String" DbType="NVarChar(10)" CanBeNull="True" />  
          <Column Name="Country" Type="System.String" DbType="NVarChar(15)" CanBeNull="True" />  
          <Column Name="Phone" Type="System.String" DbType="NVarChar(24)" CanBeNull="True" />  
          <Column Name="Fax" Type="System.String" DbType="NVarChar(24)" CanBeNull="True" />  
          <Association Name="FK_CustomerCustomerDemo_Customers" Member="CustomerCustomerDemos" ThisKey="CustomerID" OtherKey="CustomerID" OtherTable="CustomerCustomerDemo" DeleteRule="NO ACTION" />  
          <Association Name="FK_Orders_Customers" Member="Orders" ThisKey="CustomerID" OtherKey="CustomerID" OtherTable="Orders" DeleteRule="NO ACTION" />  
        </Type>  
      </Table>  
    

    if my understaing is right? if not, please correct me!

    Best Regards,

    Eric Du

    Tuesday, November 14, 2017 8:16 AM
  • User2048898515 posted

    Yes.

    I want the script which has create table and create procedure/view. I need to  generate from dbml.

    dbml file is uploaded in below link:

    https://drive.google.com/open?id=1OksG1vhP0isBsVJnAyCGo01uSv13YEkf

    https://expirebox.com/download/789fce96eeb913fca3076bc5454bded9.html

    Tuesday, November 14, 2017 8:53 AM