使用Entity Framework迁移数据库结构
我们有一个 DB2 数据库的 EF 模型。
是否可以使用该模型生成SQL Server数据库?然后在使用之间切换 DB2 和 SQL Server?
我们认为开发人员可以针对本地 SQL Server 数据库进行开发。
我们使用 EF 4.1。
We have a EF model of a DB2 database.
Is it possible to use this model to generate a SQL Server database? And then switch between using
DB2 and SQL Server?
We were thinking that the developers could develop against a local SQL Server database.
We use EF 4.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您自己定义字段类型,则可能会出现问题。
我一直在使用 Sql-Oracle 做这样的事情,最后,我们创建自定义属性,例如 [VarcharAttribute] 并配置实体以在 OnModelBuilder 函数中使用正确的类型名。
这可能行不通:
因为对于Oracle来说,它应该看起来像这样:
还可能存在其他问题,例如在sql-oracle合并中,表名超过30个字符,并且它在sql中工作,但在oracle中不起作用,因为表名限制为 30 个字符。
但是当你解决了这些问题之后,它就会起作用。最后我们能够从配置文件设置提供程序。
所以是的,如果您注意数据库差异,这是可能的
There can be problems with the field types, if you define them for yourself.
I have been doing such a thing with Sql-Oracle, and in the end, we where creating custom Attributes, like [VarcharAttribute] and configured the entities to use the correct typename in the OnModelBuilder function.
This might not work :
because for Oracle it should look like this :
Also there can be other problems, for example in the sql-oracle merge a table name was over 30 characters, and it worked in sql, but didn't work in oracle, because the table name was limited to 30 characters.
But after you fix these problems, then it will work. At the end we were able to set the provider from config file.
So yes, it is possible, if you take care of the database differences
老问题但是...
您不能将迁移与 IBM DB2 EF Provider 一起使用。
关于 DB2 的 EF 6(无需迁移),现在由 IBM 支持
您可以在此处找到支持 EF 的官方 nuget 包
http://www.nuget.org/packages/EntityFramework.IBM.DB2/
但它不支持迁移。
如果您需要迁移,您也可以使用此包(除了之前的包之外)
https://www.nuget.org/packages/System.Data。 DB2.EntityFramework.Migrations/
您可以在这里找到更多信息
https://db2ef6migrations.codeplex.com/
Old question but...
You can't use migrations with IBM DB2 EF Provider.
About EF 6 (without migration) for DB2, now is supported by IBM
You can find official nuget package for EF support here
http://www.nuget.org/packages/EntityFramework.IBM.DB2/
but it does not support migrations.
If you need migration you can use also this package (in addition to previous package)
https://www.nuget.org/packages/System.Data.DB2.EntityFramework.Migrations/
You can find more info here
https://db2ef6migrations.codeplex.com/