CodeFirst(CTP5)和默认值 [英] CodeFirst (CTP5) and Default Values

查看:55
本文介绍了CodeFirst(CTP5)和默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在代码优先的流畅api中配置默认​​值?

Is there a way to configure a default value in the fluent api for Code First?

Chris

推荐答案

如果数据库生成了默认值,则应该能够使用.HadDatabaseGenerationOption。下面是一个例子:

If your default value is generated by the database you should be able to use .HadDatabaseGenerationOption. Here is an example:


modelBuilder.Entity<Entity>().Property(p => p.Date).HasDatabaseGenerationOption(DatabaseGenerationOption.Computed);


这篇关于CodeFirst(CTP5)和默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆