Note On <Programming Entity Framework 2nd Edition> -04
来源:互联网 发布:应用市场软件 编辑:程序博客网 时间:2024/05/16 18:22
Setting Default Values
"You can also set default values in your database, so why define defaults directly in the model? The CustomerTypeID property is non-nullable. Not only is this defined in the database, but it is also defined in the conceptual model. Because it’s non-nullable in the conceptual model, you must provide a value for this property; otherwise, when you call SaveChanges, a run-time exception will be thrown. Therefore, setting the default in the model ensures that some value is provided even when the developer doesn’t specifically assign the property value."
Mapping Stored Procedure
The mapping of DeletePayment stored procedure is different from this textbook.
Really? How?When a payment is updated, the database will automatically update the RowVersion field. The UpdatePayment procedure returns the new value.
Many-To-Many Relationhips
These tables did not appear in the model as entities. The EDM has the ability to represent many-to-many relationships while hiding the join in the mappings. But it can do this only when the join table has just the relevant keys and no additional fields. These two tables meet that criterion, as they have only the IDs of the items they are joining. If the join tables had additional properties, such as DateCreated, the EDM would have created entities for them.
Building Assembly
When a project containing an EDMX is compiled, the compiler extracts the StorageModels, ConceptualModels, and Mappings sections of the EDMX file and creates individual schema files from them. In this case, the files are BAModel.ssdl, BAModel.csdl, and BAModel.msl. By default, these files are embedded into the assembly that is built from the project.
If you look at the metadata portion of the EntityConnection string that the Entity Data Model Wizard inserted into the app.config file, you’ll see the following notation:
res://*/BAModel.csdl|res://*/BAModel.ssdl|res://*/BAModel.msl
Much of the functionality in the Entity Framework depends on its ability to read the schema files. The * in the metadata of the connection string indicates that you can find the files in an assembly. Entity Framework will search all loaded assemblies until it finds the one with these embedded files.
- Note On <Programming Entity Framework 2nd Edition> -04
- Note On <Programming Entity Framework 2nd Edition> -03
- Note On <Programming Entity Framework 2nd Edition> -05
- Note On <Programming Entity Framework 2nd Edition> -01: How to Use LINQPad 4.5
- Note On <Programming Entity Framework 2nd Edition> -02: How to Use SqlExpress Profiler 2.0
- Concrete Mathematics(2nd Edition) - A Note on Notation
- Programming C# (2nd Edition)
- Programming C# (2nd Edition)
- 《Programming Pearls》 2nd Edition
- programming php,2nd Edition
- Windows Azure Platform 2nd Edition Note
- Windows Forms 2.0 Programming (2nd Edition)
- Essentials of Programming Languages - 2nd Edition
- Windows Forms 2.0 Programming (2nd Edition)
- Programming Jakarta Struts, 2nd Edition
- Programming .NET Components, 2nd Edition [ILLUSTRATED]
- .NET Framework Essentials (2nd Edition)
- Windows Azure Platform 2nd Edition Note 2
- Ubuntu 12.04下安装 Tomcat
- 安卓相对布局的一个小问题记录
- onvif 客户端发现
- 设计模式——适配器模式
- android中Bitmap图像处理 修改图片大小以及保存时的文件大小
- Note On <Programming Entity Framework 2nd Edition> -04
- android解决工具类中没有context中的问题
- RabbitMQ使用实践
- Leetcode --Sudoku Solver
- oracle官方文档之V$SESSION
- Linux如何查看so中函数名
- CentOS 7中没有ifconfig命令,而且不能发现eth0
- 获取罗辑思维每天的微信语音(python)
- C语言及程序设计初步例程-40 穷举法解题