0

我正在使用现有数据库,我的常规方法是添加一个新的实体数据模型并将其指向现有数据库。如果我要使用 EF 电动工具和逆向工程师使其成为“代码优先”风格,这有什么优势?

两者都是从 DbContext 继承的类,对吗?那么,如果我改用 EF 电动工具逆向工程工具,有人可以向我解释随着时间的推移使用代码库会有什么优势吗?

4

1 回答 1

1

Code First to an existing database generates your model (at runtime) from your C# classes. Database First stores the model inside of an .edmx file and generates your classes (at design time).

The video Entity Framework Development Workflows gives a good overview. Ultimately, it comes down to whether you want to maintain your model using a designer surface or using C# classes.

It is also worth mentioning that, if you want to use Code First Migrations, you have to use Code First since it currently doesn't work with Database First.

于 2013-08-22T16:18:22.940 回答