开发者

LINQ and Stored procedures DBML updating problem

I am having serious frustration with DBML files not updating when I alter my stored procedures.

This is what happens. I alter my stored procedure. I then delete the stored procedure from the .DBML file and re-add it. It updates correctly in the .DBML file but the .designer.cs file does not get updated. The only workaround I have found is to delete the stored procedure, then delete the table that the stored p开发者_开发知识库rocedure returns, add the table then add the stored procedure (all in the .DBML file). And this only sometimes does the trick.

Has anyone else had this problem? Surely there is a more suitable way to update DBML files in Visual Studio 2008?

Thanks in advance


There is no way DBML file gets updated as and when you change the SP.

I have a suggestion for you to get rid of it. This is what we followed in our projects.

Whenever you have update in your SP whether it is input or output parameters. Edit the dbml file as xml file (you can use open as xml in VS only) and save the dbml file. That will automatically updates the changes in designer.cs file as well. In this way you dont have to delete the SP from dbml and re-add it to get the updates. Though this is manual process but it really helps you a lot.

This way you can even modify the entity names (to comply with your entity naming conventions) for the output you are getting from SP as those default names are same as the SP name.


LINQ and Stored procedures DBML updating problem

one more thing what i did was , opened server explorer from view. there it will list the db connections. there right click on that particular connection which points to your database and refresh. If you have added any new stored procedures or if you have updated any, it will automatically get updated.


1 keep in mind that SQL and VS is completely 2 separate services. it just connect together, doesn't mean it sync each other.

2 In my opinion DBML is kinda ms-sql only. i use to create DB Factory entirely operate base on interfaces and return data as DataTable ot DataSet. This code could use for all standard db.


Also in Entity Framework 6 this is a problem. Delete the altered elements in the .edmx file and "Update Model from Database".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜