使用实体框架从模型生成数据库时列命名与旧数据库不匹配
我有一个旧数据库,我正在尝试在其中安装新代码,当我尝试使用从模型生成数据库来往返模式时,我在一些没有(并且目前可以)的表上发现列名不匹配没有)外键到位。当我生成 SQL 时,多对多引用表上的列名称会在 ID 列前面加上主表名称:
-- Creating table 'GroupUser'
CREATE TABLE [dbo].[GroupUser] (
[Groups_GroupID] int NOT NULL,
[Users_UserID] int NOT NULL
);
GO
而不是原始(遗留):
-- Creating table 'GroupUser'
CREATE TABLE [dbo].[GroupUser] (
[GroupID] int NOT NULL,
[UserID] int NOT NULL
);
GO
还有许多其他列获得类似的“升级”,这令人困惑用我的存储过程。有没有一种简单的方法可以覆盖这种行为?
I have a legacy database that I am trying to fit new code over and when I try and round trip the schema using Generate Database From Model, I am getting column name mismatches on some of the tables that don't have (and currently can't have) foreign keys in place. When I generate the SQL, the column names on a Many-to-Many referential table get the main table name prepended to the ID columns:
-- Creating table 'GroupUser'
CREATE TABLE [dbo].[GroupUser] (
[Groups_GroupID] int NOT NULL,
[Users_UserID] int NOT NULL
);
GO
rather than the original (legacy):
-- Creating table 'GroupUser'
CREATE TABLE [dbo].[GroupUser] (
[GroupID] int NOT NULL,
[UserID] int NOT NULL
);
GO
There are many other columns getting similar 'upgrades' which is futzing with my stored procedures. Is there a simple way to override this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码优先数据注释。具体来说,ColumnAttribute
Code First Data Annotations. Specifically, ColumnAttribute