开发者

.NET 4.0 EDMX Generate DB from model and then Execute SQL removes the DATA from Table

开发者 https://www.devze.com 2023-02-19 03:29 出处:网络
I\'m newbie with .NET Entity Framework 4.0 I\'m using VS2010 and I created the EDMX file and then added my Entities in this model. After I\'ve finished my Datamodel and set the Asscociation, I right c

I'm newbie with .NET Entity Framework 4.0 I'm using VS2010 and I created the EDMX file and then added my Entities in this model. After I've finished my Datamodel and set the Asscociation, I right click on and choose Generate DB from model.

Then it creates SQL scripts *.sql then I open the SQL and right click on Execute SQL Statements... What happens is all my tables are re-created...

ISSUE: All my test data in MasterData Tables are removed/deleted. I need to add the data back again manually...

I googled on "keep data generated Data model EDMX" etc. but couldn't开发者_运维技巧 find... Can someone advice me how I can avoid this problem?

Because I've e..g 15 MasterDataTable + other tables linked with these and I need to re-add the records back manually for all these tables... and 9 of 10 case I don't touch those tables in UI.

please advice how I can avoid this situation.

thanks


You can update the model from the database (the reverse way you are taking now):

Double click the .edmx file to open the designer. In the middle of the designer, right click to show the contextual menu and click "update model from database". It will prompt a screen, check the DB parameters and click next. Now, you're in a sreen with TABS. The first tab is for adding tables as entities to the model. The second tab will its for update the model. Select the tables and views you need to add/update and click next. That's all.

0

精彩评论

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