惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - bela liu

生成PDF文档,并在PDF文档结尾加印章 silverlight: 关于dataform的commit silverlight:datagrid滚动 win7下chm打不开 MS DTC 无法正确处理DC升级/降级事件。MS DTC 将继续运行并使用现有的安全设置。 远程桌面如果超出最大连接数, 使用命令行mstsc /console登录即可。 windows server 2008 安装live mail windows server 2008 安装 MSN Help: DCOM中设定"launch permission"的问题 Qt 学习(1) 使用firefox的一个小技巧 - bela liu - 博客园 现有一车(千里马)过年从苏州回赣榆,15号或者17号出发,21号,23号或者25号返程。 在Oracle中申明与某个字段类型相同的变量 几道Python的习题 在ReportViewer中使用超链接(HyperLink) 未解之Bug (1) : 必须放在具有 runat=server 的窗体标记内 在window.showModelessDialog打开的窗体中调用原窗体的alert会使IE死掉。 [转]面向对象与数据模型 在模式窗体中提交而不打开新窗体
EF CodeFirst 学习 1 - 用fluent API设置元数据,
bela liu · 2011-06-13 · via 博客园 - bela liu

用 Fluent API 设置元数据

http://agilenet.wordpress.com/2011/04/11/entity-framework-4-1-rc-with-an-existing-database/

-

03public int Id { get; set; }
04public string CompanyName { get; set; }
05public Country HomeCountry { get; set; }
10public int Id { get; set; }
11public string Code { get; set; }
12public string Name { get; set; }

public class MyContext: DbContext

04public DbSet<Company> Companies { get; set; }
05public DbSet<Country> Countries { get; set; }
07public MyContext(string connectionString): base(connectionString)
09Database.SetInitializer<MyContext>(null);
12protected override void OnModelCreating(DbModelBuilder modelBuilder)
14modelBuilder.Configurations.Add(new CountryConfiguration());
15modelBuilder.Configurations.Add(new CompanyConfiguration());
16base.OnModelCreating(modelBuilder);

public class CompanyConfiguration: EntityTypeConfiguration<Company>

04public CompanyConfiguration(): base()
09    HasColumnName("Id").
10    HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
12Property(p => p.CompanyName).
13    HasColumnName("Name").
15HasRequired(x => x.HomeCountry).
17    Map(x => x.MapKey("HomeCountryId"));
23public class CountryConfiguration: EntityTypeConfiguration<Country>
26public CountryConfiguration(): base()
29    Property(p => p.Id)
30    .HasColumnName("Id")
31    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
34    .HasColumnName("Code")
37    .HasColumnName("Name")

posted on 2011-06-13 23:14  bela liu  阅读(696)  评论()    收藏  举报