C# where does the dbml file come from?

前端 未结 5 1356
你的背包
你的背包 2020-12-29 03:31

I am currently learning C# and LINQ. I have lots of questions about them. Basically, I need a step by step tutorial.

  1. I suppose the dbml file is

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 04:09

    this link learn how to create dbml File in your Project :

    http://dotnetlearners.com/linq/linq-to-sql-creating-dbml-file

    Implement LINQ to SQL first we have to create the DBML file, the DBML file contains the C# source code which allow us to write the LINQ Queries to SQL. Here is the step by step process to generate dbml file.

    Right click on the project (or project folder) and select the option Add New Item.

    add-new-item Select LINQ to SQL Classes Template and Give Name as MyDB.dbml.

    linq-to-sql-classess

    Click on Yes when the below confirmation displayed.

    dialog

    MyDB.dbml file will be added under App_Code folder.

    dbml

    Expand Server Explorer and Right click on the Data Connections and select the option Add Connection.

    add-connection

    Add Connection Pop up will be opened, give the SQL Server details and select the then click on OK button.

    server-detail

    Database will be added under Data Connections as shown below.

    server-explorer

    Drag the table in the left pane and if primary key & foreign key relations are there then it will automatically show as shown below.

    drag-tables

    Drag the stored procedures to the right pane.

    drag-store-procedures

    Related C# code will be automatically generated and we can see by opening the file MyDB.designer.cs.

    dbml-designer-cs

提交回复
热议问题