开发者

EF CTP5 - Can't find "Database First" Examples

开发者 https://www.devze.com 2023-02-16 07:39 出处:网络
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 bigges

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" mod开发者_开发问答el generation code.

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

Thanks


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.


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?

0

精彩评论

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

关注公众号