English 中文(简体)
改用现有的非行共同的初级钥匙?
原标题:Changing to Shared Primary Key on Existing DB?

我有这样的现有表格结构:

AnimalTable
-------------
|Id         |
|Color      |
|Weight     |
|AnimalType |
-------------

CatTable
----------------
|Id            |
|MeowSound     |
|AnimalTableId |
----------------

DogTable
----------------
|Id            |
|BarkSound     |
|AnimalTableId |
----------------

AnimalType要么是“Cat”要么是“Dog”。 基本上,它具有一种“可变型”结构,加上动物可再生的“AnimalType”分解器。 这显然是一个有争议的例子,但我的项目也有类似的安排,在相当一段时间内一直在使用。 我们开始改换一些 st子,以使用《欧洲法典》第一种方法,我也希望使用同样的chem法,因此,我有一个抽象的<代码>Animal 类别和具体的<代码>Cat和Dog

从零敲碎打中确定这一点似乎非常简单,但我不敢肯定,改变我现有表格中的主要要点的最佳途径是,像我一直在使用所有电子工具一样。 是否有任何人这样做,并且能够提供一些建议/指示? 提前感谢。

最佳回答

我最后撰写了一份储存程序,基本上删除了<代码>Id栏,放在<代码>CatTable和<编码>上,改名为<代码>AnimalTableId,并使之成为主要内容。 很方便,但难部分是撰写一些内容,笼统地确定在<代码>上已经指出的所有外国钥匙。 缩略语 Id 。

问题回答

升级文字。

你们今后会因计划的其他变化而面临同样的决定。 在您的发展中,你可以重新确定这些班级,让EF为你们创建数据库。 当你去生产时,你还需要生产提升产量的文字。

改变主要关键用途:

EXEC sp_rename  CatTable.Id ,  AnimalTableId ,  COLUMN ;




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签