简体   繁体   English

如何在EF5中首先使用模型覆盖SaveChanges

[英]How to Override SaveChanges Using Model First in EF5

How can I override the SaveChanges() method in EF5 WITHOUT using a code-first approach? 如何不使用代码优先方法覆盖EF5中的SaveChanges()方法? Some of my tables use a char(32) PK (basically, a stripped down GUID) that must be stuffed prior to save. 我的某些表使用char(32)PK(基本上是简化的GUID),在保存之前必须将其填充。 Same with the audit trail. 与审计跟踪相同。 Every search I have tried always assumes that a code-first approach and NOT model-first. 我尝试过的每次搜索都始终假定是代码优先的方法,而不是模型优先的方法。

The generated context class is partial. 生成的上下文类是局部的。 Just add another code file where you extend the class and override SaveChanges there. 只需在扩展类的位置添加另一个代码文件,并在那里覆盖SaveChanges

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM