EF CTP5 - 找不到“数据库优先”示例

发布于 2024-10-21 12:35:47 字数 429 浏览 2 评论 0原文

我是 CTP 新手,刚刚下载了 CTP5。我有一个现有的数据库,在迭代开发周期的几个月里,我一直在不断地重新生成我的 *.edmx 文件。最令人头痛的问题之一是每次重新生成 *.edmx 文件时,我都必须手动进入并修复问题。浪费大量时间。例如,我有一个表,其中包含 BillingAddressID 和 HomeAddressID 字段,这两个字段都是我的地址表的 FK。当 EF 向导为我生成模型时,这些模型将显示为 Address 和 Address1。我必须手动进入设计器并将它们重命名为 BillingAddress 和 HomeAddress。

我希望通过 CTP5,有人可以插入生成管道并在每次重新生成时自动修复模型。但所有的例子似乎都是“代码优先”,我找不到任何如何插入“数据库优先”模型生成代码的例子。

CTP5可以做到这一点吗?如果是这样,有人可以给我指点教程或示例吗?

谢谢

I'm brand new to CTP, just downloaded CTP5. I have an existing database that I have been constantly regenerating my *.edmx file from for months during iterative cycles of development. One of the biggest headaches has been that every time I regen the *.edmx file I have to manually go in and fix things. A HUGE time waste. For instance, I have a table that has a BillingAddressID and HomeAddressID fields, both of which are FK's to my Address table. When the EF Wizard generates my model for me these come out as Address and Address1. I have to manually go into the designer and rename these to BillingAddress and HomeAddress.

I'm hoping that with CTP5 I can someone plug into the pipeline of generation and automatically fix the model each time I regenerate. But all the examples out there seem to be "code first", I can't find any examples of how plug into the "database first" model generation code.

Can this be done with CTP5? If so, can anyone point me to a tutorial or sample?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对你而言 2024-10-28 12:35:47

我想知道你的模型的哪些属性被重命名了?从数据库更新模型时,不会修改对实体 (CSDL) 所做的更改。只有对 SSDL(数据库描述)的手动更改才会被覆盖。当然,如果您只是删除 EDMX 并让 VS 创建新的,您的更改就会丢失。

如果您想使用 CTP5 具有 EDMX 功能 这是可能的,但您使用的是与现在相同的 EDMX,因此如果您在 EDMX 处理方面遇到一些问题,此问题将持续存在。

I wonder what properties of your model are renamed? Changes made to entities (CSDL) are not modified when updating model from database. Only manual changes to SSDL (database description) are overwritten. Of course if you just delete your EDMX and let VS create the new one your changes are lost.

If you want to use CTP5 features with EDMX it is possible BUT you are using same EDMX as now so if you have some problems with EDMX processing this problems will persist.

百合的盛世恋 2024-10-28 12:35:47

http ://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx

它不会为您生成模型, codefirst 的重点是编写您自己的 POCO。但它确实支持数据库优先的场景。

更新
我刚刚做了一个快速实验,发现在我重命名 EDMX 设计工具生成的列的情况下(根据您的问题示例),我仍然可以运行“从数据库更新模型”工具(右键单击在设计界面上,选择从数据库更新模型),它不会覆盖我的更改。

您没有手动编辑生成的代码文件,是吗?

http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx

It's not going to generate models for you, the point of codefirst is to write your own POCOs. But it does support the db-first scenario.

Update
I just did a quick experiment, and found that in scenarios where I renamed columns that the EDMX design tool generated (as per your example of what the problem w/ it is), I could still run the Update Model from Database tool (right click on design surface, choose Update Model From Database) and it would not overwrite my changes.

You're not hand-editing the generated code files are you?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文