當前位置:首頁 » 操作系統 » 從資料庫生成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最後在彈出的界面中選擇要建模的資料庫版本,即可生成建模語言

熱點內容
安卓的AndroidAuto 發布:2025-05-13 19:41:49 瀏覽:357
下載安裝python 發布:2025-05-13 19:39:21 瀏覽:27
蘋果手機如何退出ad密碼 發布:2025-05-13 19:35:24 瀏覽:353
資本論中央編譯局 發布:2025-05-13 19:21:50 瀏覽:134
python路徑是否存在 發布:2025-05-13 19:08:38 瀏覽:570
保時捷卡宴哪個配置比較好 發布:2025-05-13 19:00:08 瀏覽:725
c語言負數運算 發布:2025-05-13 18:45:21 瀏覽:428
太空殺電腦版連接不到伺服器 發布:2025-05-13 18:40:19 瀏覽:457
同樣的配置為什麼跑分不同 發布:2025-05-13 18:39:06 瀏覽:279
獲取linuxcpu序列號 發布:2025-05-13 18:36:35 瀏覽:738