生成的sql在使用linqpad实体框架dll时尝试创建表

时间:2013-12-13 16:15:38

标签: entity-framework linqpad

我试图运行一个非常简单的(从地址中的x选择x)。使用我自己的实体框架dll查询(1​​0))我得到了这个异常。

SQLEXCEPTION 数据库中已有一个名为“Contact”的对象

当我转到sql生成的代码时,它正在执行此操作:

SELECT TABLE_SCHEMA SchemaName, TABLE_NAME Name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
GO

SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[__MigrationHistory] AS [Extent1]
)  AS [GroupBy1]
GO

SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[__MigrationHistory] AS [Extent1]
)  AS [GroupBy1]
GO

SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[__MigrationHistory] AS [Extent1]
)  AS [GroupBy1]
GO

SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[__MigrationHistory] AS [Extent1]
)  AS [GroupBy1]
GO

SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[__MigrationHistory] AS [Extent1]
)  AS [GroupBy1]
GO

SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[__MigrationHistory] AS [Extent1]
)  AS [GroupBy1]
GO

CREATE TABLE [dbo].[Contact] (
    [OwnerId] [uniqueidentifier] NOT NULL,
    [OwnerIdDsc] [int] NOT NULL,
    [ContactId] [uniqueidentifier] NOT NULL,
    [StateCode] [int] NOT NULL,
    [trad_lregionidName] [nvarchar](100),
    [et_lastbouncesendidName] [nvarchar](100),
    [TransactionCurrencyIdName] [nvarchar](100),
    [PreferredSystemUserIdName] [nvarchar](160),
    [trad_lbrandidName] [nvarchar](100),
    [CreatedOnBehalfByName] [nvarchar](160),
    [CreatedByYomiName] [nvarchar](160),
    [trad_lcampaignidName] [nvarchar](128),
    [trad_lcompanyreportingidName] [nvarchar](100),
    [trad_lrelationshipmgridName] [nvarchar](160),
    [MasterContactIdYomiName] [nvarchar](450),
    [PreferredEquipmentIdName] [nvarchar](160),
    [trad_laccount1accounttype1idName] [nvarchar](100),
    [PreferredSystemUserIdYomiName] [nvarchar](160),
    [MasterContactIdName] [nvarchar](160),
    [trad_lrelationshipmgridYomiName] [nvarchar](160),
    [OriginatingLeadIdYomiName] [nvarchar](450),
    [ModifiedByName] [nvarchar](160),
    [ModifiedOnBehalfByName] [nvarchar](160),
    [CreatedOnBehalfByYomiName] [nvarchar](160),
    [ModifiedOnBehalfByYomiName] [nvarchar](160), ... goes on

...

关于为什么要尝试创建表格的任何想法?

1 个答案:

答案 0 :(得分:1)

我遇到了类似的问题,这篇文章为我解决了问题:http://jameschambers.com/2014/02/changing-the-namespace-with-entity-framework-6-0-code-first-databases/

基本上,这是迁移之间EF迁移配置类的命名空间更改问题:表__MigrationHistory保留对旧命名空间的引用。