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

熱點內容
酷派內置存儲空間不足 發布:2025-09-16 15:50:44 瀏覽:396
php設置編碼格式 發布:2025-09-16 15:20:04 瀏覽:609
php取兩位小數點 發布:2025-09-16 15:12:40 瀏覽:312
加密塊流加密 發布:2025-09-16 15:07:36 瀏覽:697
sqldeveloper導出表 發布:2025-09-16 15:07:33 瀏覽:363
xbox360ftp 發布:2025-09-16 14:45:34 瀏覽:848
火車站附近wifi密碼是多少 發布:2025-09-16 14:45:30 瀏覽:191
國家標准加密 發布:2025-09-16 14:45:27 瀏覽:950
php集成支付寶 發布:2025-09-16 14:05:28 瀏覽:719
php的pregmatchall 發布:2025-09-16 14:04:43 瀏覽:438