當前位置:首頁 » 操作系統 » 從資料庫生成model

從資料庫生成model

發布時間: 2023-02-06 21:44:19

⑴ 如何從資料庫生成 EF Code First model

http://msdn.microsoft.com/en-us/gg558520

這句話很好的解釋了EDM是個啥玩意。

At
its core, the ADO.NET Entity Framework relies on an Entity Data Model.
An EDM provides all the metadata the framework needs to translate LINQ
queries into

SQL commands
and materialize objects from query results. This metadata includes a
storage model (which describes a database schema), a conceptual model

(which describes entities used in the application), and the mapping between the storage and conceptual models.

1.用T4模版生成POCO Entiteshttp://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx

2.codefirst是先代碼後生成資料庫的,此文介紹了如何從資料庫生成codefirst models http://weblogs.asp.net/jgalloway/archive/2011/02/24/generating-ef-code-first-model-classes-from-an-existing-database.aspx 一下部分是原文過來的。

⑵ 如何從資料庫生成 EF Code First model

默認情況下,資料庫是創建在localhost\SQLEXPRESS伺服器上,並且默認的資料庫名為命名空間+context類名,例如我們前面的BreakAway.BreakAwayContext。

有幾種方法可以改變這種默認約定。
利用配置文件
在配置文件中新加一個連接字元串
<connectionStrings>
<add name="BreakAwayContext" providerName="System.Data.SqlClient" connectionString="Server=.\SQLEXPRESS;Database=BreakAwayConfigFile;Trusted_Connection=true" />
</connectionStrings>

注意這里連接字元串名稱和我們的context類名相同,都為BreakAwayContext。我們修改了一下默認的資料庫名,將BreakAway.BreakAwayContext
改為BreakAwayConfigFile。

我們在新增一個連接字元串
<connectionStrings>
<!--<add name="BreakAwayContext" providerName="System.Data.SqlClient" connectionString="Server=.\SQLEXPRESS;Database=BreakAwayConfigFile;Trusted_Connection=true" />-->
<add name="My_Test" providerName="System.Data.SqlClient" connectionString="Server=.;Database=MyBreakAwayDb;Trusted_Connection=true" />
</connectionStrings>

新建的連接串名稱和context類名不同了,所以我們要在BreakAwayContext的構造函數中指名連接串的名稱:

public class BreakAwayContext : DbContext
{
public BreakAwayContext():
base("name=My_Test")
{
}
}

⑶ 如何使用PowerDesign進行資料庫建模操作方法都有什麼呢

如何使用PowerDesign進行資料庫建模?操作方法都有什麼呢?

操作方法

01首先打開PowerDesign軟體,點擊頂部的文件菜單,從下拉菜單中選擇新建選項

02接下來,在彈出的新界面中選擇概念數據模型選項,然後給模型命名

07然後雙擊關系線,在關系界面設置實體間的關系類型,包括一對多、一對一、多對多

08接下來,我們單擊頂部的Tools菜單,並在下拉菜單中選擇Generate Physical Data Model選項

09最後在彈出的界面中選擇要建模的資料庫版本,即可生成建模語言

熱點內容
如何改變拉桿箱上的初始密碼 發布:2024-04-25 11:17:23 瀏覽:798
內網掛代理虛擬機如何配置網卡 發布:2024-04-25 11:15:06 瀏覽:686
明日之後緩存怎麼清理 發布:2024-04-25 11:14:56 瀏覽:204
華為mate30怎麼退回安卓版 發布:2024-04-25 11:08:49 瀏覽:897
安卓新機使用前要注意什麼 發布:2024-04-25 11:03:46 瀏覽:810
藍鳥哪個配置有按摩 發布:2024-04-25 10:53:24 瀏覽:939
崩壞3要求什麼蘋果手機配置 發布:2024-04-25 10:36:59 瀏覽:142
培訓機構國內訪問學者 發布:2024-04-25 10:34:28 瀏覽:911
java靜態類 發布:2024-04-25 10:25:09 瀏覽:484
python函數圖像 發布:2024-04-25 10:17:29 瀏覽:914