EDMX创建没有表

时间:2015-11-19 08:36:54

标签: asp.net-mvc entity-framework asp.net-mvc-4

我创建了2个模型,它们之间有关联 enter image description here

然后我尝试从模型生成数据库 enter image description here enter image description here enter image description here

这是我的AccountingSystemModel.edmx.sql脚本

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/19/2015 11:31:04
-- Generated from EDMX file: E:\C#\Project\EF_5_ModelFirst\EF_5_ModelFirst\AccountingSystemModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [AccountingSystem];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_InvoiceHeaderInvoiceDetail]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[InvoiceDetailSet] DROP CONSTRAINT [FK_InvoiceHeaderInvoiceDetail];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[InvoiceHeaderSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[InvoiceHeaderSet];
GO
IF OBJECT_ID(N'[dbo].[InvoiceDetailSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[InvoiceDetailSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'InvoiceHeaderSet'
CREATE TABLE [dbo].[InvoiceHeaderSet] (
    [InvoiceHeader_Id] int IDENTITY(1,1) NOT NULL,
    [Total] decimal(18,0)  NOT NULL
);
GO

-- Creating table 'InvoiceDetailSet'
CREATE TABLE [dbo].[InvoiceDetailSet] (
    [InvoiceDetail_Id] int IDENTITY(1,1) NOT NULL,
    [ItemDescription] nvarchar(max)  NOT NULL,
    [Quantity] nvarchar(max)  NOT NULL,
    [Price] nvarchar(max)  NOT NULL,
    [InvoiceHeaderInvoiceHeader_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [InvoiceHeader_Id] in table 'InvoiceHeaderSet'
ALTER TABLE [dbo].[InvoiceHeaderSet]
ADD CONSTRAINT [PK_InvoiceHeaderSet]
    PRIMARY KEY CLUSTERED ([InvoiceHeader_Id] ASC);
GO

-- Creating primary key on [InvoiceDetail_Id] in table 'InvoiceDetailSet'
ALTER TABLE [dbo].[InvoiceDetailSet]
ADD CONSTRAINT [PK_InvoiceDetailSet]
    PRIMARY KEY CLUSTERED ([InvoiceDetail_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [InvoiceHeaderInvoiceHeader_Id] in table 'InvoiceDetailSet'
ALTER TABLE [dbo].[InvoiceDetailSet]
ADD CONSTRAINT [FK_InvoiceHeaderInvoiceDetail]
    FOREIGN KEY ([InvoiceHeaderInvoiceHeader_Id])
    REFERENCES [dbo].[InvoiceHeaderSet]
        ([InvoiceHeader_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoiceHeaderInvoiceDetail'
CREATE INDEX [IX_FK_InvoiceHeaderInvoiceDetail]
ON [dbo].[InvoiceDetailSet]
    ([InvoiceHeaderInvoiceHeader_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

我执行了它,得到了消息Command(s) completed successfully.
但是在创建的数据库中没有表 enter image description here
我不明白为什么?我做错了什么?

0 个答案:

没有答案