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

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:573
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:864
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:561
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:743
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:664
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:985
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:233
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:93
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:786
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:691