开发者

What is the equivalent of DataContext in entity framework?

开发者 https://www.devze.com 2023-03-09 11:48 出处:网络
Linq to SQL has this very simple model: DataContext and attributes [Table] and [Column] and no need for a config file.

Linq to SQL has this very simple model: DataContext and attributes [Table] and [Column] and no need for a config file.

But I understand Linq2SQL does not 开发者_开发知识库have a future.

How do I do something equivalent in entity framework?

(Equivalent = no config file)


In EF 4.1 Code-First you can configure your mapping in a fluent way as opposed to a config file.

It is convention based so it will infer lot of thing from your model (eg: Table column are automatically mapped to properties if both names match).EF Code First Model


In EF also we create a context from edmx file through which you can access all the entities(tables in Database). Refer to this article in msdn.

It also adds the connection string to the config file. If you just want to use entities then you dont need a config entry.

But EF is used with database operations most of the time.

0

精彩评论

暂无评论...
验证码 换一张
取 消