| ylbtech-ADO.NET-EF:ADO.NET Entity Framework 百科 |
ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R Mapping) 解决方案。该框架曾经为.NET Framework的一部分,但version 6之后从.NET Framework分离出来。
| 1.返回顶部 |
| 2.返回顶部 |
|
版本
|
支持.NET
|
发布情况
|
备注
|
|
Entity Framework 3.5
|
2.0+
|
包含于.NET 3.5中
|
支持EDMX生成,通过扩展可支持POCO类的生成
|
|
Entity Framework 4.0
|
4.0+
|
包含于.NET 4.0中
|
|
|
Entity Framework 4.X
|
4.0+
|
可通过NuGet获取
|
支持Database First、Model First、Code First三种生
成模式
|
|
Entity Framework 4.5
|
4.5+
|
集成于.NET 4.5中
|
|
|
Entity Framework 5.X
|
4.5+
|
可通过NuGet获取
|
支持枚举字段,性能有较大提升,支持.NET 4.0的版本
为Entity Framework 4.4
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<?xml version="1.0" encoding="utf-8"?><EntityContainer Name="EmployeesContext"><EntitySet Name="Employees" EntityType="Employees.Employees" /></EntityContainer><EntityType Name="Employees"><Key><PropertyRef Name="EmployeeId" /></Key><Property Name="EmployeeId" Type="Guid" Nullable="false" /><Property Name="LastName" Type="String" Nullable="false" /><Property Name="FirstName" Type="String" Nullable="false" /><Property Name="Email" Type="String" Nullable="false" /></EntityType></Schema> |
|
1
2
3
4
5
6
7
8
9
10
11
|
<?xml version="1.0" encoding="utf-8"?><Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"><EntityContainerMapping StorageEntityContainer="dbo" CdmEntityContainer="EmployeesContext"><EntitySetMapping Name="Employees" StoreEntitySet="Employees" TypeName="Employees.Employees"><ScalarProperty Name="EmployeeId" ColumnName="EmployeeId" /><ScalarProperty Name="LastName" ColumnName="LastName" /><ScalarProperty Name="FirstName" ColumnName="FirstName" /><ScalarProperty Name="Email" ColumnName="Email" /></EntitySetMapping></EntityContainerMapping></Mapping> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
?xml version="1.0" encoding="utf-8"?><Schema Namespace="Employees.Store" Alias="Self"Provider="System.Data.SqlClient"ProviderManifestToken="2005"<EntityContainer Name="dbo"><EntitySet Name="Employees" EntityType="Employees.Store.Employees" /></EntityContainer><EntityType Name="Employees"><Key><PropertyRef Name="EmployeeId" /></Key><Property Name="EmployeeId" Type="uniqueidentifier" Nullable="false" /><Property Name="LastName" Type="nvarchar" Nullable="false" MaxLength="50" /><Property Name="FirstName" Type="nvarchar" Nullable="false" /><Property Name="Email" Type="nvarchar" Nullable="false" /></EntityType></Schema> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Initialize the EntityConnectionStringBuilder.EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();//Set the provider name.entityBuilder.Provider = providerName;// Set the provider-specific connection string.entityBuilder.ProviderConnectionString = providerString;// Set the Metadata location.entityBuilder.Metadata = @"res://*/AdventureWorksModel.csdl|res://*/AdventureWorksModel.ssdl|res://*/AdventureWorksModel.msl";Console.WriteLine(entityBuilder.ToString());using (EntityConnection conn = new EntityConnection(entityBuilder.ToString())){conn.Open();Console.WriteLine("Just testing the connection.");conn.Close();} |
|
1
2
3
4
5
|
// Get the contacts with the specified name.ObjectQuery<Contact> contactQuery = context.Contact.Where("it.LastName = @ln AND it.FirstName = @fn",new ObjectParameter("ln", lastName),new ObjectParameter("fn", firstName)); |
|
1
2
3
4
5
6
|
using (AdventureWorksEntities AWEntities = new AdventureWorksEntities()){ObjectQuery<Product> products = AWEntities.Product;IQueryable<Product> productNames =from p in productsselect p; |
| 3.返回顶部 |
| 4.返回顶部 |
| 5.返回顶部 |
| 6.返回顶部 |
| 作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
ADO.NET-EF:ADO.NET Entity Framework 百科
原文:https://www.cnblogs.com/storebook/p/11429579.html