是否可以从Visual Studio 2008中的edmx更新sql数据库架构?

时间:2022-02-09 10:22:58

So with LINQ-to-SQL I know you can update the database from the LINQ objects and update the LINQ objects from the SQL.

因此,使用LINQ-to-SQL,我知道您可以从LINQ对象更新数据库并从SQL更新LINQ对象。

I am using LINQ's entity framework (a.k.a. LINQ-to-entities) and I can update the entities from the SQL database, but I can't update the database schema by changing the entities.

我正在使用LINQ的实体框架(a.k.a. LINQ-to-entities),我可以从SQL数据库更新实体,但我无法通过更改实体来更新数据库模式。

This is frustrating. Is there something I am missing? Am I doing something wrong? If this is not possible with Visual Studio 2008 is there a plug-in or other 3rd party application that will do this?

这令人沮丧。有什么我想念的吗?难道我做错了什么?如果使用Visual Studio 2008无法实现这一点,是否有插件或其他第三方应用程序可以执行此操作?

2 个解决方案

#1


Right now the EF model can only be generated from the database. The database cannot be generated from the model.

现在只能从数据库生成EF模型。无法从模型生成数据库。

Something that is talked about for future versions.

未来版本中谈到的东西。

#2


I have been working on extending the LINQ to SQL Database Sync(*) (csdb.exe) tool to work with edmx files. For now, I have got a preliminary, but working, version that can generate and update tables in your database. Relations are not working yet, and you will probably run into some other issues. The code is available on github, under the Ms-PL (as was the original csdb.exe).

我一直在努力扩展LINQ to SQL Database Sync(*)(csdb.exe)工具以使用edmx文件。目前,我有一个初步但有效的版本,可以生成和更新数据库中的表。关系还没有成功,你可能会遇到其他一些问题。该代码可以在Ms-PL下的github上获得(与原始的csdb.exe一样)。

Please note the database connection string and edmx filename are hardcoded for now. This is my prototyping version, not a release one ;)

请注意,数据库连接字符串和edmx文件名现在都是硬编码的。这是我的原型版本,而不是发布版本;)

(*) Please google the original tool. Stack Overflow does not allow me to post more than one link...

(*)请谷歌原始工具。 Stack Overflow不允许我发布多个链接...

#1


Right now the EF model can only be generated from the database. The database cannot be generated from the model.

现在只能从数据库生成EF模型。无法从模型生成数据库。

Something that is talked about for future versions.

未来版本中谈到的东西。

#2


I have been working on extending the LINQ to SQL Database Sync(*) (csdb.exe) tool to work with edmx files. For now, I have got a preliminary, but working, version that can generate and update tables in your database. Relations are not working yet, and you will probably run into some other issues. The code is available on github, under the Ms-PL (as was the original csdb.exe).

我一直在努力扩展LINQ to SQL Database Sync(*)(csdb.exe)工具以使用edmx文件。目前,我有一个初步但有效的版本,可以生成和更新数据库中的表。关系还没有成功,你可能会遇到其他一些问题。该代码可以在Ms-PL下的github上获得(与原始的csdb.exe一样)。

Please note the database connection string and edmx filename are hardcoded for now. This is my prototyping version, not a release one ;)

请注意,数据库连接字符串和edmx文件名现在都是硬编码的。这是我的原型版本,而不是发布版本;)

(*) Please google the original tool. Stack Overflow does not allow me to post more than one link...

(*)请谷歌原始工具。 Stack Overflow不允许我发布多个链接...