联系我们
cms新闻网站系统、政府cms定制开发

广州网站建设公司-阅速公司

报纸新媒体网站内容发布一体化解决方案联系电话
/
http://www.kize.icu/
广州网站建设公司
您当前位置:首页>ASP.NET MVC

ASP.NET MVC

asp.net mvc3.0 Code First 如何更新数据库?

发布时间:2013/7/17 8:34:10  作者:Admin  阅读:82  

更新数据库,只需要在Nuget控制台输入 Update-Database -Verbose 即可

成功后会显示如下信息:

 

PM> Update-Database -Verbose

Using StartUp project 'TopWin.Etone.Domain'.

Using NuGet project 'TopWin.Etone.Domain'.

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.

Target database is: '您的数据库' (DataSource: .\SQL2008, Provider: System.Data.SqlClient, Origin: Convention).

No pending code-based migrations.

Applying automatic migration: 201307170029571_AutomaticMigration.

CREATE TABLE [dbo].[AirCode] (

[AirCodeID] [int] NOT NULL IDENTITY,

[AirportCode] [nvarchar](max),

[AirportNameCN] [nvarchar](max),

[AirportNameEN] [nvarchar](max),

[CityCode] [nvarchar](max),

[CityNameCN] [nvarchar](max),

[CityNameEN] [nvarchar](max),

[ProvinceCode] [nvarchar](max),

[ProvinceNameCN] [nvarchar](max),

[ProvinceNameEN] [nvarchar](max),

[CountryCode] [nvarchar](max),

[CountryNameCN] [nvarchar](max),

[Continent] [nvarchar](max),

[Capital] [nvarchar](max),

CONSTRAINT [PK_dbo.AirCode] PRIMARY KEY ([AirCodeID])

)

CREATE TABLE [dbo].[Department] (

[DepartmentID] [int] NOT NULL IDENTITY,

[DepName] [nvarchar](max) NOT NULL,

[ParentID] [int] NOT NULL,

[DepNum] [nvarchar](max),

[DepPhone] [nvarchar](max),

[Director] [nvarchar](max),

[DirectorID] [int],

[Level] [smallint] NOT NULL,

[SN] [smallint],

CONSTRAINT [PK_dbo.Department] PRIMARY KEY ([DepartmentID])

)

CREATE TABLE [dbo].[Role] (

[RoleID] [int] NOT NULL IDENTITY,

[RoleName] [nvarchar](max) NOT NULL,

[Description] [nvarchar](max),

[RoleStatus] [smallint] NOT NULL,

[privilege] [nvarchar](max),

[Menu] [nvarchar](max),

[Fn] [nvarchar](max),

CONSTRAINT [PK_dbo.Role] PRIMARY KEY ([RoleID])

)

CREATE TABLE [dbo].[Account] (

[AccountID] [int] NOT NULL IDENTITY,

[FullName] [varchar](32) NOT NULL,

[Password] [varchar](128) NOT NULL,

[UserName] [varchar](32) NOT NULL,

[Email] [varchar](64),

[Phone] [varchar](32),

[Photo] [varchar](128),

[DepName] [nvarchar](max),

[DepNum] [nvarchar](max),

[PositionID] [int] NOT NULL,

[PositionName] [nvarchar](max),

[AccountStatus] [int] NOT NULL,

[Gender] [int] NOT NULL,

[EntryDate] [datetime],

CONSTRAINT [PK_dbo.Account] PRIMARY KEY ([AccountID])

)

CREATE TABLE [dbo].[Position] (

[PositionID] [int] NOT NULL IDENTITY,

[PositionName] [nvarchar](max) NOT NULL,

[ParentID] [int] NOT NULL,

[PositionNum] [nvarchar](max),

[SN] [int] NOT NULL,

[Path] [nvarchar](max),

CONSTRAINT [PK_dbo.Position] PRIMARY KEY ([PositionID])

)

CREATE TABLE [dbo].[Menu] (

[MenuID] [int] NOT NULL IDENTITY,

[MenuName] [nvarchar](max) NOT NULL,

[Icon] [nvarchar](max),

[SN] [int] NOT NULL,

[ParentID] [int] NOT NULL,

[MenuStatus] [int] NOT NULL,

[Url] [nvarchar](max),

[Params] [nvarchar](max),

[MenuLevel] [int] NOT NULL,

[Path] [nvarchar](max),

CONSTRAINT [PK_dbo.Menu] PRIMARY KEY ([MenuID])

)

CREATE TABLE [dbo].[Fn] (

[FnID] [int] NOT NULL IDENTITY,

[FnName] [nvarchar](max) NOT NULL,

[FnKey] [nvarchar](max),

[Icon] [nvarchar](max),

[MenuID] [int] NOT NULL,

[SN] [smallint],

[FnStatus] [smallint],

[Url] [nvarchar](max),

CONSTRAINT [PK_dbo.Fn] PRIMARY KEY ([FnID])

)

CREATE TABLE [dbo].[Document] (

[DocumentID] [int] NOT NULL IDENTITY,

[DocName] [nvarchar](max),

[Property] [nvarchar](max),

[Airline] [nvarchar](max),

[DocType] [nvarchar](max),

[DocClass] [nvarchar](max),

[ValidPeriod] [datetime] NOT NULL,

[ComeFrom] [nvarchar](max),

[DocContent] [nvarchar](max),

[FileIDs] [nvarchar](max),

[CreateTime] [datetime] NOT NULL,

[UpdateTime] [datetime] NOT NULL,

[DictoryID] [int] NOT NULL,

CONSTRAINT [PK_dbo.Document] PRIMARY KEY ([DocumentID])

)

CREATE TABLE [dbo].[Attachment] (

[AttachmentID] [int] NOT NULL IDENTITY,

[Path] [nvarchar](max) NOT NULL,

[AttachmentName] [nvarchar](max) NOT NULL,

[ExtName] [nvarchar](max),

[CreateTime] [datetime] NOT NULL,

[CreatorID] [int] NOT NULL,

[Creator] [nvarchar](max),

[Description] [nvarchar](max),

[FileSize] [nvarchar](max),

[AttachmentType] [nvarchar](max),

[TotalBytes] [int] NOT NULL,

CONSTRAINT [PK_dbo.Attachment] PRIMARY KEY ([AttachmentID])

)

CREATE TABLE [dbo].[Dictory] (

[DictoryID] [int] NOT NULL IDENTITY,

[DictoryName] [nvarchar](max),

[Path] [nvarchar](max),

[ParentID] [int] NOT NULL,

CONSTRAINT [PK_dbo.Dictory] PRIMARY KEY ([DictoryID])

)

CREATE TABLE [dbo].[Tree] (

[TreeID] [int] NOT NULL IDENTITY,

[ParentID] [int] NOT NULL,

[NodeName] [varchar](32) NOT NULL,

[NodeKey] [varchar](64) NOT NULL,

[CategoryKey] [nvarchar](max),

[CategoryID] [int] NOT NULL,

[SN] [int] NOT NULL,

[Path] [nvarchar](max),

CONSTRAINT [PK_dbo.Tree] PRIMARY KEY ([TreeID])

)

CREATE TABLE [dbo].[Category] (

[CategoryID] [int] NOT NULL IDENTITY,

[CategoryName] [varchar](32) NOT NULL,

[CategoryKey] [varchar](32) NOT NULL,

[SN] [int] NOT NULL,

CONSTRAINT [PK_dbo.Category] PRIMARY KEY ([CategoryID])

)

CREATE TABLE [dbo].[Dic] (

[DicID] [int] NOT NULL IDENTITY,

[TreeID] [int] NOT NULL,

[ItemName] [nvarchar](max) NOT NULL,

[ItemValue] [nvarchar](max),

[Description] [nvarchar](max),

[SN] [int] NOT NULL,

CONSTRAINT [PK_dbo.Dic] PRIMARY KEY ([DicID])

)

CREATE TABLE [dbo].[SysConfig] (

[ConfigID] [int] NOT NULL IDENTITY,

[ConfigKey] [nvarchar](max) NOT NULL,

[ConfigName] [nvarchar](max) NOT NULL,

[ConfigType] [nvarchar](max) NOT NULL,

[Description] [nvarchar](max),

[ConfigValue] [nvarchar](max),

CONSTRAINT [PK_dbo.SysConfig] PRIMARY KEY ([ConfigID])

)

CREATE TABLE [dbo].[Company] (

[CompanyID] [int] NOT NULL IDENTITY,

[CompanyName] [nvarchar](max),

[CompanyDesc] [nvarchar](max),

[Phone] [nvarchar](max),

[Fax] [nvarchar](max),

[Site] [nvarchar](max),

[Logo] [nvarchar](max),

CONSTRAINT [PK_dbo.Company] PRIMARY KEY ([CompanyID])

)

CREATE TABLE [dbo].[Tip] (

[TipID] [int] NOT NULL IDENTITY,

[TipName] [nvarchar](max),

[TipContent] [nvarchar](max),

[DisHeight] [int] NOT NULL,

[DisWidth] [int] NOT NULL,

[DisLeft] [int] NOT NULL,

[DisTop] [int] NOT NULL,

[DisLevel] [int] NOT NULL,

[CreateTime] [datetime] NOT NULL,

[AccountID] [int] NOT NULL,

CONSTRAINT [PK_dbo.Tip] PRIMARY KEY ([TipID])

)

CREATE TABLE [dbo].[Customer] (

[CustomerID] [int] NOT NULL IDENTITY,

[CustomerName2] [nvarchar](max),

[ShortName] [nvarchar](max),

[Address] [nvarchar](max),

[SalesID] [int] NOT NULL,

[Sales] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatorName] [nvarchar](max),

[CreatedTime] [datetime],

[CustomerType] [nvarchar](max),

[CustomerClass] [nvarchar](max),

[LinkMan] [nvarchar](max),

[Phone] [nvarchar](max),

[Fax] [nvarchar](max),

[Mobile] [nvarchar](max),

[Email] [nvarchar](max),

[Website] [nvarchar](max),

[DepName] [nvarchar](max),

[DepNum] [nvarchar](max),

[Notes] [nvarchar](max),

CONSTRAINT [PK_dbo.Customer] PRIMARY KEY ([CustomerID])

)

CREATE TABLE [dbo].[CustomerFile] (

[CustomerFileID] [int] NOT NULL IDENTITY,

[AttachmentID] [int] NOT NULL,

[FileName] [nvarchar](max),

[CreateTime] [datetime] NOT NULL,

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CustomerID] [int] NOT NULL,

[CustomerName] [nvarchar](max),

[Description] [nvarchar](max),

CONSTRAINT [PK_dbo.CustomerFile] PRIMARY KEY ([CustomerFileID])

)

CREATE TABLE [dbo].[Follows] (

[FollowsID] [int] NOT NULL IDENTITY,

[FollowsMan] [nvarchar](max),

[FollowTime] [datetime] NOT NULL,

[FollowType] [nvarchar](max),

[FollowContent] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[CustomerName] [nvarchar](max),

[DepNum] [nvarchar](max),

CONSTRAINT [PK_dbo.Follows] PRIMARY KEY ([FollowsID])

)

CREATE TABLE [dbo].[Contacts] (

[ContactsID] [int] NOT NULL IDENTITY,

[ContactsName] [nvarchar](max),

[Gender] [int] NOT NULL,

[Phone] [nvarchar](max),

[Mobile] [nvarchar](max),

[Fax] [nvarchar](max),

[Email] [nvarchar](max),

[Title] [nvarchar](max),

[Department] [nvarchar](max),

[ContactsType] [nvarchar](max),

[Notes] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[CustomerName] [nvarchar](max),

[EnglishName] [nvarchar](max),

[Nationality] [nvarchar](max),

[Identification] [nvarchar](max),

[PassportID] [nvarchar](max),

[Birthday] [datetime] NOT NULL,

[PassportVT] [datetime] NOT NULL,

[MenbershipCardType] [nvarchar](max),

[MenbershipCardNum] [nvarchar](max),

[AttachmentID] [int],

CONSTRAINT [PK_dbo.Contacts] PRIMARY KEY ([ContactsID])

)

CREATE TABLE [dbo].[Supplier] (

[SupplierID] [int] NOT NULL IDENTITY,

[SupplierName] [nvarchar](max),

[ShortName] [nvarchar](max),

[SupplierType] [nvarchar](max),

[LinkMan] [nvarchar](max),

[Address] [nvarchar](max),

[Phone] [nvarchar](max),

[Mobile] [nvarchar](max),

[Fax] [nvarchar](max),

[Email] [nvarchar](max),

[Notes] [nvarchar](max),

[Website] [nvarchar](max),

CONSTRAINT [PK_dbo.Supplier] PRIMARY KEY ([SupplierID])

)

CREATE TABLE [dbo].[OrderNo] (

[OrderNoID] [int] NOT NULL IDENTITY,

[OrderNoName] [nvarchar](max),

[OreryNoKey] [nvarchar](max),

[Prefix] [nvarchar](max),

[DateStr] [nvarchar](max),

[CurrentNo] [int] NOT NULL,

CONSTRAINT [PK_dbo.OrderNo] PRIMARY KEY ([OrderNoID])

)

CREATE TABLE [dbo].[SalesOrder] (

[SalesOrderID] [int] NOT NULL IDENTITY,

[ReturnStatus] [int] NOT NULL,

[SalesOrderDir] [int] NOT NULL,

[SalesOrderType] [nvarchar](max),

[SalesOrderNum] [nvarchar](max),

[BKSalesOrderNum] [nvarchar](max),

[CustomerName] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[Company] [nvarchar](max),

[CreateTime] [datetime] NOT NULL,

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[Notes] [nvarchar](max),

[AmountReceivable] [float] NOT NULL,

[AmountPayable] [float] NOT NULL,

[Profit] [float] NOT NULL,

[Received] [float] NOT NULL,

[Payabled] [float] NOT NULL,

[ReceiveStatus] [int] NOT NULL,

[PayStatus] [int] NOT NULL,

[Supplier] [nvarchar](max),

[SupplierID] [int] NOT NULL,

[Travaller] [nvarchar](max),

[Airline] [nvarchar](max),

[Route] [nvarchar](max),

[TicketNo] [nvarchar](max),

[PNR] [nvarchar](max),

[AmountRebate] [float] NOT NULL,

[RestaurantOrderNum] [nvarchar](max),

[RestaurantCity] [nvarchar](max),

[RestaurantName] [nvarchar](max),

[RestaurantBeginDate] [datetime],

[RestaurantEndDate] [datetime],

[RestaurantNightCount] [int] NOT NULL,

[RestaurantCheckInStatus] [int] NOT NULL,

[RestaurantTotalMoney] [float] NOT NULL,

[VisaName] [nvarchar](max),

[VisaCountry] [nvarchar](max),

[VisaType] [nvarchar](max),

[InsuranceCompany] [nvarchar](max),

[InsuranceNum] [nvarchar](max),

[InsuranceBeginDate] [datetime],

[InsuranceEndDate] [datetime],

[Insurant] [nvarchar](max),

[InsuranceType] [nvarchar](max),

[EntranceTicketName] [nvarchar](max),

CONSTRAINT [PK_dbo.SalesOrder] PRIMARY KEY ([SalesOrderID])

)

CREATE TABLE [dbo].[SalesOrderItem] (

[SalesOrderItemID] [int] NOT NULL IDENTITY,

[SalesOrderID] [int] NOT NULL,

[SalesChargeStatus] [int] NOT NULL,

[SalesPackagedStatus] [int] NOT NULL,

[ItemMaster] [nvarchar](max),

[SalesOrderNum] [nvarchar](max),

[SalesOrderType] [nvarchar](max),

[SalesOrderDir] [int] NOT NULL,

[CustomerName] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[Company] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

[Receivable] [float] NOT NULL,

[Received] [float] NOT NULL,

[UnReceived] [float] NOT NULL,

[Notes] [nvarchar](max),

[Travaller] [nvarchar](max),

[Ticket] [float] NOT NULL,

[Tax] [float] NOT NULL,

[Airline] [nvarchar](max),

[Route] [nvarchar](max),

[TicketNo] [nvarchar](max),

[PNR] [nvarchar](max),

[Formula] [nvarchar](max),

[RestaurantRoomType] [nvarchar](max),

[RestaurantMan] [nvarchar](max),

[RestaurantRoomCount] [nvarchar](max),

[RestaurantPrice] [nvarchar](max),

[RestaurantOtherCost] [nvarchar](max),

[RestaurantOrderNum] [nvarchar](max),

[RestaurantCity] [nvarchar](max),

[RestaurantName] [nvarchar](max),

[RestaurantBeginDate] [datetime],

[RestaurantEndDate] [datetime],

[RestaurantNightCount] [int] NOT NULL,

[RestaurantTotalMoney] [float] NOT NULL,

[RestaurantCheckInStatus] [int] NOT NULL,

[RestaurantPayBackPCT] [float] NOT NULL,

[VisaName] [nvarchar](max),

[VisaCountry] [nvarchar](max),

[VisaType] [nvarchar](max),

[VisaFormula] [nvarchar](max),

[Insurant] [nvarchar](max),

[InsuranceType] [nvarchar](max),

[InsuranceFormula] [nvarchar](max),

[InsuranceCompany] [nvarchar](max),

[InsuranceNum] [nvarchar](max),

[EntranceTicketType] [nvarchar](max),

[EntranceTicketSort] [nvarchar](max),

[EntranceTicketName] [nvarchar](max),

[EntranceTicketNo] [nvarchar](max),

[EntranceTicketDate] [datetime],

[EntranceTicketFormula] [nvarchar](max),

[EntranceTicketCount] [int] NOT NULL,

CONSTRAINT [PK_dbo.SalesOrderItem] PRIMARY KEY ([SalesOrderItemID])

)

CREATE TABLE [dbo].[SalesItemPackage] (

[SalesItemPackageID] [int] NOT NULL IDENTITY,

[ItemPackageNum] [nvarchar](max),

[AmountPackage] [float] NOT NULL,

[CustomerName] [nvarchar](max),

[CustomerID] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

[Notes] [nvarchar](max),

[PackageStatus] [int] NOT NULL,

[Company] [nvarchar](max),

CONSTRAINT [PK_dbo.SalesItemPackage] PRIMARY KEY ([SalesItemPackageID])

)

CREATE TABLE [dbo].[SalesChargeList] (

[SalesChargeListID] [int] NOT NULL IDENTITY,

[SalesChargeOffID] [int] NOT NULL,

[ChargeOffNum] [nvarchar](max),

[ReceivedInID] [int] NOT NULL,

[ReceivedInNum] [nvarchar](max),

[SalesItemPackageID] [int] NOT NULL,

[ItemPackageNum] [nvarchar](max),

[SalesOrderItemID] [int] NOT NULL,

[SalesOrderNum] [nvarchar](max),

[ItemMaster] [nvarchar](max),

[Receivable] [float] NOT NULL,

[Received] [float] NOT NULL,

[CurrentReceived] [float] NOT NULL,

[UnReceived] [float] NOT NULL,

[CustomerName] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[Company] [nvarchar](max),

[SalesOrderDir] [nvarchar](max),

[SalesOrderType] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

CONSTRAINT [PK_dbo.SalesChargeList] PRIMARY KEY ([SalesChargeListID])

)

CREATE TABLE [dbo].[SalesChargeOff] (

[SalesChargeOffID] [int] NOT NULL IDENTITY,

[ChargeOffNum] [nvarchar](max),

[ReceivedInID] [int] NOT NULL,

[ReceivedInNum] [nvarchar](max),

[SalesItemPackageID] [int] NOT NULL,

[ItemPackageNum] [nvarchar](max),

[Amount] [float] NOT NULL,

[AmountLeft] [float] NOT NULL,

[AmountPackage] [float] NOT NULL,

[ReceivedTime] [datetime] NOT NULL,

[Attached] [nvarchar](max),

[Payment] [nvarchar](max),

[CustomerName] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[Company] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

CONSTRAINT [PK_dbo.SalesChargeOff] PRIMARY KEY ([SalesChargeOffID])

)

CREATE TABLE [dbo].[ReceivedIn] (

[ReceivedInID] [int] NOT NULL IDENTITY,

[ReceivedInNum] [nvarchar](max),

[Payment] [nvarchar](max),

[ReceivedInType] [int] NOT NULL,

[Amount] [float] NOT NULL,

[Used] [float] NOT NULL,

[UnUsed] [float] NOT NULL,

[DivReceived] [float] NOT NULL,

[DivPayed] [float] NOT NULL,

[CustomerName] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[Company] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

[Notes] [nvarchar](max),

[ReceivedInStatus] [int] NOT NULL,

[AttachmentID] [int],

CONSTRAINT [PK_dbo.ReceivedIn] PRIMARY KEY ([ReceivedInID])

)

CREATE TABLE [dbo].[PurchaseOrderItem] (

[PurchaseOrderItemID] [int] NOT NULL IDENTITY,

[SalesOrderID] [int] NOT NULL,

[PurchaseChargeStatus] [int] NOT NULL,

[PurchasePackagedStatus] [int] NOT NULL,

[ItemMaster] [nvarchar](max),

[SalesOrderNum] [nvarchar](max),

[SalesOrderType] [nvarchar](max),

[SalesOrderDir] [int] NOT NULL,

[CustomerName] [nvarchar](max),

[CustomerID] [int] NOT NULL,

[Company] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

[Payable] [float] NOT NULL,

[Payabled] [float] NOT NULL,

[UnPayabled] [float] NOT NULL,

[Supplier] [nvarchar](max),

[SupplierID] [int] NOT NULL,

[Notes] [nvarchar](max),

[Travaller] [nvarchar](max),

[Ticket] [float] NOT NULL,

[Tax] [float] NOT NULL,

[Airline] [nvarchar](max),

[Route] [nvarchar](max),

[TicketNo] [nvarchar](max),

[PNR] [nvarchar](max),

[Formula] [nvarchar](max),

[RebateFormula] [nvarchar](max),

[Rebate] [float] NOT NULL,

[RestaurantRoomType] [nvarchar](max),

[RestaurantMan] [nvarchar](max),

[RestaurantRoomCount] [nvarchar](max),

[RestaurantPrice] [nvarchar](max),

[RestaurantOtherCost] [nvarchar](max),

[RestaurantOrderNum] [nvarchar](max),

[RestaurantCity] [nvarchar](max),

[RestaurantName] [nvarchar](max),

[RestaurantBeginDate] [datetime],

[RestaurantEndDate] [datetime],

[RestaurantNightCount] [int] NOT NULL,

[VisaName] [nvarchar](max),

[VisaCountry] [nvarchar](max),

[VisaType] [nvarchar](max),

[VisaFormula] [nvarchar](max),

[Insurant] [nvarchar](max),

[InsuranceType] [nvarchar](max),

[InsuranceFormula] [nvarchar](max),

[InsuranceCompany] [nvarchar](max),

[InsuranceNum] [nvarchar](max),

[EntranceTicketType] [nvarchar](max),

[EntranceTicketSort] [nvarchar](max),

[EntranceTicketName] [nvarchar](max),

[EntranceTicketNo] [nvarchar](max),

[EntranceTicketDate] [datetime],

[EntranceTicketFormula] [nvarchar](max),

[EntranceTicketCount] [int] NOT NULL,

CONSTRAINT [PK_dbo.PurchaseOrderItem] PRIMARY KEY ([PurchaseOrderItemID])

)

CREATE TABLE [dbo].[PurchaseItemPackage] (

[PurchaseItemPackageID] [int] NOT NULL IDENTITY,

[ItemPackageNum] [nvarchar](max),

[AmountPackage] [float] NOT NULL,

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[Company] [nvarchar](max),

[CreatedTime] [datetime] NOT NULL,

[Notes] [nvarchar](max),

[PackageStatus] [int] NOT NULL,

[Supplier] [nvarchar](max),

[SupplierID] [int] NOT NULL,

CONSTRAINT [PK_dbo.PurchaseItemPackage] PRIMARY KEY ([PurchaseItemPackageID])

)

CREATE TABLE [dbo].[PurchaseChargeList] (

[PurchaseChargeListID] [int] NOT NULL IDENTITY,

[PurchaseChargeOffID] [int] NOT NULL,

[ChargeOffNum] [nvarchar](max),

[PayOutID] [int] NOT NULL,

[PayOutNum] [nvarchar](max),

[PurchaseItemPackageID] [int] NOT NULL,

[ItemPackageNum] [nvarchar](max),

[PurchaseOrderItemID] [int] NOT NULL,

[SalesOrderNum] [nvarchar](max),

[ItemMaster] [nvarchar](max),

[Payable] [float] NOT NULL,

[Payabled] [float] NOT NULL,

[CurrentPayabled] [float] NOT NULL,

[UnPayabled] [float] NOT NULL,

[Supplier] [nvarchar](max),

[SupplierID] [int] NOT NULL,

[Company] [nvarchar](max),

[SalesOrderDir] [nvarchar](max),

[SalesOrderType] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

CONSTRAINT [PK_dbo.PurchaseChargeList] PRIMARY KEY ([PurchaseChargeListID])

)

CREATE TABLE [dbo].[PurchaseChargeOff] (

[PurchaseChargeOffID] [int] NOT NULL IDENTITY,

[ChargeOffNum] [nvarchar](max),

[PayOutID] [int] NOT NULL,

[PayOutNum] [nvarchar](max),

[PurchaseItemPackageID] [int] NOT NULL,

[ItemPackageNum] [nvarchar](max),

[Amount] [float] NOT NULL,

[AmountLeft] [float] NOT NULL,

[AmountPackage] [float] NOT NULL,

[PayOutTime] [datetime] NOT NULL,

[Attached] [nvarchar](max),

[Payment] [nvarchar](max),

[Supplier] [nvarchar](max),

[SupplierID] [int] NOT NULL,

[Company] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

CONSTRAINT [PK_dbo.PurchaseChargeOff] PRIMARY KEY ([PurchaseChargeOffID])

)

CREATE TABLE [dbo].[PayOut] (

[PayOutID] [int] NOT NULL IDENTITY,

[PayOutNum] [nvarchar](max),

[Payment] [nvarchar](max),

[RebatePayOut] [int] NOT NULL,

[PayOutType] [int] NOT NULL,

[Amount] [float] NOT NULL,

[Used] [float] NOT NULL,

[UnUsed] [float] NOT NULL,

[DivPayed] [float] NOT NULL,

[DivReceived] [float] NOT NULL,

[SupplierName] [nvarchar](max),

[SupplierID] [int] NOT NULL,

[Company] [nvarchar](max),

[Creator] [nvarchar](max),

[CreatorID] [int] NOT NULL,

[CreatedTime] [datetime] NOT NULL,

[Notes] [nvarchar](max),

[PayOutStatus] [int] NOT NULL,

[AttachmentID] [int],

CONSTRAINT [PK_dbo.PayOut] PRIMARY KEY ([PayOutID])

)

CREATE TABLE [dbo].[AccountRoles] (

[AccountID] [int] NOT NULL,

[RoleID] [int] NOT NULL,

CONSTRAINT [PK_dbo.AccountRoles] PRIMARY KEY ([AccountID], [RoleID])

)

CREATE TABLE [dbo].[RoleMenus] (

[RoleID] [int] NOT NULL,

[MenuID] [int] NOT NULL,

CONSTRAINT [PK_dbo.RoleMenus] PRIMARY KEY ([RoleID], [MenuID])

)

CREATE TABLE [dbo].[RoleFns] (

[RoleID] [int] NOT NULL,

[FnID] [int] NOT NULL,

CONSTRAINT [PK_dbo.RoleFns] PRIMARY KEY ([RoleID], [FnID])

)

CREATE TABLE [dbo].[DocAttach] (

[DocumentID] [int] NOT NULL,

[AttachmentID] [int] NOT NULL,

CONSTRAINT [PK_dbo.DocAttach] PRIMARY KEY ([DocumentID], [AttachmentID])

)

CREATE TABLE [dbo].[SalesPackageItem] (

[SalesItemPackageID] [int] NOT NULL,

[SalesOrderItemID] [int] NOT NULL,

CONSTRAINT [PK_dbo.SalesPackageItem] PRIMARY KEY ([SalesItemPackageID], [SalesOrderItemID])

)

CREATE TABLE [dbo].[PurchasePackageItem] (

[PurchaseItemPackageID] [int] NOT NULL,

[PurchaseOrderItemID] [int] NOT NULL,

CONSTRAINT [PK_dbo.PurchasePackageItem] PRIMARY KEY ([PurchaseItemPackageID], [PurchaseOrderItemID])

)

CREATE INDEX [IX_PositionID] ON [dbo].[Account]([PositionID])

CREATE INDEX [IX_MenuID] ON [dbo].[Fn]([MenuID])

CREATE INDEX [IX_DictoryID] ON [dbo].[Document]([DictoryID])

CREATE INDEX [IX_CategoryID] ON [dbo].[Tree]([CategoryID])

CREATE INDEX [IX_AccountID] ON [dbo].[Tip]([AccountID])

CREATE INDEX [IX_AttachmentID] ON [dbo].[CustomerFile]([AttachmentID])

CREATE INDEX [IX_AttachmentID] ON [dbo].[Contacts]([AttachmentID])

CREATE INDEX [IX_SalesOrderID] ON [dbo].[SalesOrderItem]([SalesOrderID])

CREATE INDEX [IX_SalesChargeOffID] ON [dbo].[SalesChargeList]([SalesChargeOffID])

CREATE INDEX [IX_ReceivedInID] ON [dbo].[SalesChargeList]([ReceivedInID])

CREATE INDEX [IX_SalesItemPackageID] ON [dbo].[SalesChargeList]([SalesItemPackageID])

CREATE INDEX [IX_SalesOrderItemID] ON [dbo].[SalesChargeList]([SalesOrderItemID])

CREATE INDEX [IX_AttachmentID] ON [dbo].[ReceivedIn]([AttachmentID])

CREATE INDEX [IX_SalesOrderID] ON [dbo].[PurchaseOrderItem]([SalesOrderID])

CREATE INDEX [IX_PurchaseChargeOffID] ON [dbo].[PurchaseChargeList]([PurchaseChargeOffID])

CREATE INDEX [IX_PayOutID] ON [dbo].[PurchaseChargeList]([PayOutID])

CREATE INDEX [IX_PurchaseItemPackageID] ON [dbo].[PurchaseChargeList]([PurchaseItemPackageID])

CREATE INDEX [IX_PurchaseOrderItemID] ON [dbo].[PurchaseChargeList]([PurchaseOrderItemID])

CREATE INDEX [IX_AttachmentID] ON [dbo].[PayOut]([AttachmentID])

CREATE INDEX [IX_AccountID] ON [dbo].[AccountRoles]([AccountID])

CREATE INDEX [IX_RoleID] ON [dbo].[AccountRoles]([RoleID])

CREATE INDEX [IX_RoleID] ON [dbo].[RoleMenus]([RoleID])

CREATE INDEX [IX_MenuID] ON [dbo].[RoleMenus]([MenuID])

CREATE INDEX [IX_RoleID] ON [dbo].[RoleFns]([RoleID])

CREATE INDEX [IX_FnID] ON [dbo].[RoleFns]([FnID])

CREATE INDEX [IX_DocumentID] ON [dbo].[DocAttach]([DocumentID])

CREATE INDEX [IX_AttachmentID] ON [dbo].[DocAttach]([AttachmentID])

CREATE INDEX [IX_SalesItemPackageID] ON [dbo].[SalesPackageItem]([SalesItemPackageID])

CREATE INDEX [IX_SalesOrderItemID] ON [dbo].[SalesPackageItem]([SalesOrderItemID])

CREATE INDEX [IX_PurchaseItemPackageID] ON [dbo].[PurchasePackageItem]([PurchaseItemPackageID])

CREATE INDEX [IX_PurchaseOrderItemID] ON [dbo].[PurchasePackageItem]([PurchaseOrderItemID])

ALTER TABLE [dbo].[Account] ADD CONSTRAINT [FK_dbo.Account_dbo.Position_PositionID] FOREIGN KEY ([PositionID]) REFERENCES [dbo].[Position] ([PositionID]) ON DELETE CASCADE

ALTER TABLE [dbo].[Fn] ADD CONSTRAINT [FK_dbo.Fn_dbo.Menu_MenuID] FOREIGN KEY ([MenuID]) REFERENCES [dbo].[Menu] ([MenuID]) ON DELETE CASCADE

ALTER TABLE [dbo].[Document] ADD CONSTRAINT [FK_dbo.Document_dbo.Dictory_DictoryID] FOREIGN KEY ([DictoryID]) REFERENCES [dbo].[Dictory] ([DictoryID]) ON DELETE CASCADE

ALTER TABLE [dbo].[Tree] ADD CONSTRAINT [FK_dbo.Tree_dbo.Category_CategoryID] FOREIGN KEY ([CategoryID]) REFERENCES [dbo].[Category] ([CategoryID]) ON DELETE CASCADE

ALTER TABLE [dbo].[Tip] ADD CONSTRAINT [FK_dbo.Tip_dbo.Account_AccountID] FOREIGN KEY ([AccountID]) REFERENCES [dbo].[Account] ([AccountID]) ON DELETE CASCADE

ALTER TABLE [dbo].[CustomerFile] ADD CONSTRAINT [FK_dbo.CustomerFile_dbo.Attachment_AttachmentID] FOREIGN KEY ([AttachmentID]) REFERENCES [dbo].[Attachment] ([AttachmentID]) ON DELETE CASCADE

ALTER TABLE [dbo].[Contacts] ADD CONSTRAINT [FK_dbo.Contacts_dbo.Attachment_AttachmentID] FOREIGN KEY ([AttachmentID]) REFERENCES [dbo].[Attachment] ([AttachmentID])

ALTER TABLE [dbo].[SalesOrderItem] ADD CONSTRAINT [FK_dbo.SalesOrderItem_dbo.SalesOrder_SalesOrderID] FOREIGN KEY ([SalesOrderID]) REFERENCES [dbo].[SalesOrder] ([SalesOrderID]) ON DELETE CASCADE

ALTER TABLE [dbo].[SalesChargeList] ADD CONSTRAINT [FK_dbo.SalesChargeList_dbo.SalesChargeOff_SalesChargeOffID] FOREIGN KEY ([SalesChargeOffID]) REFERENCES [dbo].[SalesChargeOff] ([SalesChargeOffID]) ON DELETE CASCADE

ALTER TABLE [dbo].[SalesChargeList] ADD CONSTRAINT [FK_dbo.SalesChargeList_dbo.ReceivedIn_ReceivedInID] FOREIGN KEY ([ReceivedInID]) REFERENCES [dbo].[ReceivedIn] ([ReceivedInID]) ON DELETE CASCADE

ALTER TABLE [dbo].[SalesChargeList] ADD CONSTRAINT [FK_dbo.SalesChargeList_dbo.SalesItemPackage_SalesItemPackageID] FOREIGN KEY ([SalesItemPackageID]) REFERENCES [dbo].[SalesItemPackage] ([SalesItemPackageID]) ON DELETE CASCADE

ALTER TABLE [dbo].[SalesChargeList] ADD CONSTRAINT [FK_dbo.SalesChargeList_dbo.SalesOrderItem_SalesOrderItemID] FOREIGN KEY ([SalesOrderItemID]) REFERENCES [dbo].[SalesOrderItem] ([SalesOrderItemID]) ON DELETE CASCADE

ALTER TABLE [dbo].[ReceivedIn] ADD CONSTRAINT [FK_dbo.ReceivedIn_dbo.Attachment_AttachmentID] FOREIGN KEY ([AttachmentID]) REFERENCES [dbo].[Attachment] ([AttachmentID])

ALTER TABLE [dbo].[PurchaseOrderItem] ADD CONSTRAINT [FK_dbo.PurchaseOrderItem_dbo.SalesOrder_SalesOrderID] FOREIGN KEY ([SalesOrderID]) REFERENCES [dbo].[SalesOrder] ([SalesOrderID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PurchaseChargeList] ADD CONSTRAINT [FK_dbo.PurchaseChargeList_dbo.PurchaseChargeOff_PurchaseChargeOffID] FOREIGN KEY ([PurchaseChargeOffID]) REFERENCES [dbo].[PurchaseChargeOff] ([PurchaseChargeOffID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PurchaseChargeList] ADD CONSTRAINT [FK_dbo.PurchaseChargeList_dbo.PayOut_PayOutID] FOREIGN KEY ([PayOutID]) REFERENCES [dbo].[PayOut] ([PayOutID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PurchaseChargeList] ADD CONSTRAINT [FK_dbo.PurchaseChargeList_dbo.PurchaseItemPackage_PurchaseItemPackageID] FOREIGN KEY ([PurchaseItemPackageID]) REFERENCES [dbo].[PurchaseItemPackage] ([PurchaseItemPackageID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PurchaseChargeList] ADD CONSTRAINT [FK_dbo.PurchaseChargeList_dbo.PurchaseOrderItem_PurchaseOrderItemID] FOREIGN KEY ([PurchaseOrderItemID]) REFERENCES [dbo].[PurchaseOrderItem] ([PurchaseOrderItemID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PayOut] ADD CONSTRAINT [FK_dbo.PayOut_dbo.Attachment_AttachmentID] FOREIGN KEY ([AttachmentID]) REFERENCES [dbo].[Attachment] ([AttachmentID])

ALTER TABLE [dbo].[AccountRoles] ADD CONSTRAINT [FK_dbo.AccountRoles_dbo.Account_AccountID] FOREIGN KEY ([AccountID]) REFERENCES [dbo].[Account] ([AccountID]) ON DELETE CASCADE

ALTER TABLE [dbo].[AccountRoles] ADD CONSTRAINT [FK_dbo.AccountRoles_dbo.Role_RoleID] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[Role] ([RoleID]) ON DELETE CASCADE

ALTER TABLE [dbo].[RoleMenus] ADD CONSTRAINT [FK_dbo.RoleMenus_dbo.Role_RoleID] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[Role] ([RoleID]) ON DELETE CASCADE

ALTER TABLE [dbo].[RoleMenus] ADD CONSTRAINT [FK_dbo.RoleMenus_dbo.Menu_MenuID] FOREIGN KEY ([MenuID]) REFERENCES [dbo].[Menu] ([MenuID]) ON DELETE CASCADE

ALTER TABLE [dbo].[RoleFns] ADD CONSTRAINT [FK_dbo.RoleFns_dbo.Role_RoleID] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[Role] ([RoleID]) ON DELETE CASCADE

ALTER TABLE [dbo].[RoleFns] ADD CONSTRAINT [FK_dbo.RoleFns_dbo.Fn_FnID] FOREIGN KEY ([FnID]) REFERENCES [dbo].[Fn] ([FnID]) ON DELETE CASCADE

ALTER TABLE [dbo].[DocAttach] ADD CONSTRAINT [FK_dbo.DocAttach_dbo.Document_DocumentID] FOREIGN KEY ([DocumentID]) REFERENCES [dbo].[Document] ([DocumentID]) ON DELETE CASCADE

ALTER TABLE [dbo].[DocAttach] ADD CONSTRAINT [FK_dbo.DocAttach_dbo.Attachment_AttachmentID] FOREIGN KEY ([AttachmentID]) REFERENCES [dbo].[Attachment] ([AttachmentID]) ON DELETE CASCADE

ALTER TABLE [dbo].[SalesPackageItem] ADD CONSTRAINT [FK_dbo.SalesPackageItem_dbo.SalesItemPackage_SalesItemPackageID] FOREIGN KEY ([SalesItemPackageID]) REFERENCES [dbo].[SalesItemPackage] ([SalesItemPackageID]) ON DELETE CASCADE

ALTER TABLE [dbo].[SalesPackageItem] ADD CONSTRAINT [FK_dbo.SalesPackageItem_dbo.SalesOrderItem_SalesOrderItemID] FOREIGN KEY ([SalesOrderItemID]) REFERENCES [dbo].[SalesOrderItem] ([SalesOrderItemID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PurchasePackageItem] ADD CONSTRAINT [FK_dbo.PurchasePackageItem_dbo.PurchaseItemPackage_PurchaseItemPackageID] FOREIGN KEY ([PurchaseItemPackageID]) REFERENCES [dbo].[PurchaseItemPackage] ([PurchaseItemPackageID]) ON DELETE CASCADE

ALTER TABLE [dbo].[PurchasePackageItem] ADD CONSTRAINT [FK_dbo.PurchasePackageItem_dbo.PurchaseOrderItem_PurchaseOrderItemID] FOREIGN KEY ([PurchaseOrderItemID]) REFERENCES [dbo].[PurchaseOrderItem] ([PurchaseOrderItemID]) ON DELETE CASCADE

CREATE TABLE [dbo].[__MigrationHistory] (

[MigrationId] [nvarchar](255) NOT NULL,

[Model] [varbinary](max) NOT NULL,

[ProductVersion] [nvarchar](32) NOT NULL,

CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId])

)

BEGIN TRY

EXEC sp_MS_marksystemobject 'dbo.__MigrationHistory'

END TRY

BEGIN CATCH

END CATCH

[Inserting migration history record]

Running Seed method.

PM>

 

 

相关文章
Code First
asp.net mvc
cms新闻系统购买咨询
扫描关注 广州阅速软件科技有限公司
扫描关注 广州阅速科技
莱万特s
相扑君的逆袭返水 黑龙江11选5 六合彩一肖彩经书 维卡币2019 香港平特一肖网 15选5今天开奖结果 香港社群特码一肖中特 热血传奇海报 彩经网走势图 麻将来了猜猜乐怎么进 夏洛克的秘密注册 国际米兰埃托奥 cf手游辅助 西班牙对战阿拉维斯 刘谦魔术 悉尼fcvs墨胜利