Metadata file not found - Data.Entity.Model

错误    3    正在编译转换: 未能找到元数据文件“F:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\Microsoft.Data.Entity.Design.DatabaseGeneration.dll”    E:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\SSDLToSQL10.tt    1    1    杂项文件

原错误信息:

纠结了一半天,总算在 stackoverflow 找到了答案,

http://stackoverflow.com/questions/19664833/metadata-file-not-found-data-entity-model#

(没读懂英文的可以看我下面的分析)

问题简单分析,看下创建 EF 生成模型时候产生的 SSDLToSql10.tt(这是用于 Code First 模式下生成的一个模板文件,主要是用来生成一个 DLL SQL SCRIPT [此处没深入了解,如有不妥请指教])

  1 <# 
  2 //---------------------------------------------------------------------
  3 // <copyright file="SsdlToSql10.tt" company="Microsoft">
  4 //      Copyright (c) Microsoft Corporation.  All rights reserved.
  5 // </copyright>
  6 //---------------------------------------------------------------------
  7 // This T4 template generates T-SQL from an instance of 
  8 // System.Data.Metadata.Edm.StoreItemCollection, an object representation
  9 // of the SSDL. This T-SQL is compatible with SQL 2012, 2008, 2005, CE, and Azure databases.
 10 //---------------------------------------------------------------------
 11 // Note: We will resolve all paths in assembly directives at runtime, taking 
 12 // macros and environment variables into account (e.g. $(ProjectDir), %VS120COMNTOOLS% etc.)
 13 #>
 14 <#@ assembly name="System.Core" #>
 15 <#@ assembly name="%VS120COMNTOOLS%..\IDE\Microsoft.Data.Entity.Design.DatabaseGeneration.dll"#>
 16 <#@ assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.dll"#>
 17 <#@ assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.SqlServer.dll" #>
 18 <#@ assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.SqlServerCompact.dll" #>
 19 <#@ import namespace="System.Linq" #>
 20 <#@ import namespace="System.Text" #>
 21 <#@ import namespace="System.Collections.Generic" #>
 22 <#@ import namespace="System.Data.Entity" #>
 23 <#@ import namespace="System.Data.Entity.Core.Metadata.Edm" #>
 24 <#@ import namespace="Microsoft.Data.Entity.Design.DatabaseGeneration" #>
 25 <#@ import namespace="System.Runtime.Remoting.Messaging" #>
 26 <#@ import namespace="System.Text.RegularExpressions" #>
 27 <#@ template language="C#" debug="true" hostspecific="true" #>
 28 <#@ include file="GenerateTSQL.Utility.ttinclude"#>
 29 <#@ output extension = ".sql" #>
 30 <#
 31 
 32 // +++++++++++++++++++++++++++++++++++++++++++++++++
 33 // Setup for the template (initializing variables, etc.)
 34 // +++++++++++++++++++++++++++++++++++++++++++++++++
 35 
 36     string databaseName = this.GetInput<string>(EdmParameterBag.ParameterName.DatabaseName.ToString());
 37     string edmxPath = this.GetInput<string>(EdmParameterBag.ParameterName.EdmxPath.ToString());
 38     Version targetVersion = this.GetInput<Version>(EdmParameterBag.ParameterName.TargetVersion.ToString());
 39 
 40     DbConfiguration.SetConfiguration(new TemplateDbConfiguration());
 41 
 42     if (false == InitializeAndValidateExistingStore()) 
 43     {
 44 #>
 45 -- Warning: There were errors validating the existing SSDL. Drop statements
 46 -- will not be generated.
 47 <#
 48     }
 49 #>
 50 -- --------------------------------------------------
 51 <#
 52     if (this.IsSQLCE) {
 53 #>
 54 -- Entity Designer DDL Script for SQL Server Compact Edition
 55 <#
 56     } else {
 57 #>
 58 -- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
 59 <#
 60     }
 61 #>
 62 -- --------------------------------------------------
 63 -- Date Created: <#=DateTime.Now#>
 64 <#
 65     if (!String.IsNullOrEmpty(edmxPath))
 66     {
 67 #>
 68 -- Generated from EDMX file: <#=Id(edmxPath)#>
 69 <#
 70     }
 71 #>
 72 -- --------------------------------------------------
 73 
 74 <#  if (!this.IsSQLCE) 
 75     { 
 76 #>
 77 SET QUOTED_IDENTIFIER OFF;
 78 GO
 79 <#  if (!String.IsNullOrEmpty(databaseName))
 80     {
 81 #>
 82 USE [<#=Id(databaseName)#>];
 83 GO
 84 <#
 85     }
 86     foreach (string unescapedSchemaName in (from es in Store.GetAllEntitySets() select es.GetSchemaName()).Distinct())
 87     {
 88 #>
 89 IF SCHEMA_ID(N'<#=Lit(unescapedSchemaName)#>') IS NULL EXECUTE(N'CREATE SCHEMA [<#=Id(unescapedSchemaName)#>]');
 90 <#
 91     }
 92 #>
 93 GO
 94 <#  } #>
 95 
 96 -- --------------------------------------------------
 97 -- Dropping existing FOREIGN KEY constraints
 98 <#  if (this.IsSQLCE)
 99     {
100 #>
101 -- NOTE: if the constraint does not exist, an ignorable error will be reported.
102 <#  } #>
103 -- --------------------------------------------------
104 
105 <#
106     foreach (AssociationSet associationSet in ExistingStore.GetAllAssociationSets())
107     {
108         ReferentialConstraint constraint = associationSet.ElementType.ReferentialConstraints.Single();
109         string constraintName = Id(WriteFKConstraintName(constraint));
110         AssociationSetEnd dependentSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.ToRole).Single();
111         string schemaName = Id(dependentSetEnd.EntitySet.GetSchemaName());
112         string dependentTableName = Id(dependentSetEnd.EntitySet.GetTableName());
113         
114         if (!this.IsSQLCE)
115         {
116 #>
117 IF OBJECT_ID(N'[<#=Lit(schemaName)#>].[<#=Lit(constraintName)#>]', 'F') IS NOT NULL
118 <#      } #>
119     ALTER TABLE <# if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=dependentTableName#>] DROP CONSTRAINT [<#=constraintName#>];
120 GO
121 <#
122     }
123 #>
124 
125 -- --------------------------------------------------
126 -- Dropping existing tables
127 <#  if (this.IsSQLCE)
128     {
129 #>
130 -- NOTE: if the table does not exist, an ignorable error will be reported.
131 <#  } #>
132 -- --------------------------------------------------
133 
134 <#
135     foreach (EntitySet entitySet in ExistingStore.GetAllEntitySets())
136     { 
137         string schemaName = Id(entitySet.GetSchemaName());
138         string tableName = Id(entitySet.GetTableName());
139         
140         if (!this.IsSQLCE)
141         {
142 #>
143 IF OBJECT_ID(N'[<#=Lit(schemaName)#>].[<#=Lit(tableName)#>]', 'U') IS NOT NULL
144 <#      } #>
145     DROP TABLE <# if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=tableName#>];
146 GO
147 <#
148     }
149 #>
150 
151 -- --------------------------------------------------
152 -- Creating all tables
153 -- --------------------------------------------------
154 
155 <#
156     foreach (EntitySet entitySet in Store.GetAllEntitySets())
157     {
158         string schemaName = Id(entitySet.GetSchemaName());
159         string tableName = Id(entitySet.GetTableName());
160 #>
161 -- Creating table '<#=tableName#>'
162 CREATE TABLE <# if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=tableName#>] (
163 <#
164         for (int p = 0; p < entitySet.ElementType.Properties.Count; p++)
165         {
166             EdmProperty prop = entitySet.ElementType.Properties[p];
167 #>
168     [<#=Id(prop.Name)#>] <#=prop.ToStoreType()#> <#=WriteIdentity(prop, targetVersion)#> <#=WriteNullable(prop.Nullable)#><#=(p < entitySet.ElementType.Properties.Count - 1) ? "," : ""#>
169 <#
170         }
171 #>
172 );
173 GO
174 
175 <# 
176     } 
177 #>
178 -- --------------------------------------------------
179 -- Creating all PRIMARY KEY constraints
180 -- --------------------------------------------------
181 
182 <#
183     foreach (EntitySet entitySet in Store.GetAllEntitySets())
184     {
185         string schemaName = Id(entitySet.GetSchemaName());
186         string tableName = Id(entitySet.GetTableName());
187 #>
188 -- Creating primary key on <#=WriteColumns(entitySet.ElementType.GetKeyProperties(), ',')#> in table '<#=tableName#>'
189 ALTER TABLE <# if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=tableName#>]
190 ADD CONSTRAINT [PK_<#=tableName#>]
191     PRIMARY KEY <# if (!IsSQLCE) {#>CLUSTERED <#}#>(<#=WriteColumns(entitySet.ElementType.GetKeyProperties(), ',')#> <# if (!IsSQLCE) {#>ASC<#}#>);
192 GO
193 
194 <#
195     }
196 #>
197 -- --------------------------------------------------
198 -- Creating all FOREIGN KEY constraints
199 -- --------------------------------------------------
200 
201 <#
202     foreach (AssociationSet associationSet in Store.GetAllAssociationSets())
203     {
204         ReferentialConstraint constraint = associationSet.ElementType.ReferentialConstraints.Single();
205         AssociationSetEnd dependentSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.ToRole).Single();
206         AssociationSetEnd principalSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.FromRole).Single();
207         string schemaName = Id(dependentSetEnd.EntitySet.GetSchemaName());
208         string dependentTableName = Id(dependentSetEnd.EntitySet.GetTableName());
209         string principalTableName = Id(principalSetEnd.EntitySet.GetTableName());
210 #>
211 -- Creating foreign key on <#=WriteColumns(constraint.ToProperties, ',')#> in table '<#=dependentTableName#>'
212 ALTER TABLE <#if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=dependentTableName#>]
213 ADD CONSTRAINT [<#=WriteFKConstraintName(constraint)#>]
214     FOREIGN KEY (<#=WriteColumns(constraint.ToProperties, ',')#>)
215     REFERENCES <# if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=principalTableName#>]
216         (<#=WriteColumns(constraint.FromProperties, ',')#>)
217     ON DELETE <#=GetDeleteAction(constraint)#> ON UPDATE NO ACTION;
218 <#      
219         // if the foreign keys are part of the primary key on the dependent end, then we should not add a constraint.
220         if (!dependentSetEnd.EntitySet.ElementType.GetKeyProperties().Take(constraint.ToProperties.Count()).OrderBy(r => r.Name).SequenceEqual(constraint.ToProperties.OrderBy(r => r.Name)))
221         {
222 #>
223 
224 -- Creating non-clustered index for FOREIGN KEY '<#=WriteFKConstraintName(constraint)#>'
225 CREATE INDEX [IX_<#=WriteFKConstraintName(constraint)#>]
226 ON <#if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=dependentTableName#>]
227     (<#=WriteColumns(constraint.ToProperties, ',')#>);
228 <#      
229         }
230 #>
231 GO
232 
233 <#
234     }
235 #>
236 -- --------------------------------------------------
237 -- Script has ended
238 -- --------------------------------------------------
SSDLToSql10.tt

这里面就可以看到它引用了这几个程序集

<#@ assembly name="System.Core" #>
<#@ assembly name="%VS120COMNTOOLS%..\IDE\Microsoft.Data.Entity.Design.DatabaseGeneration.dll"#>
<#@ assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.dll"#>
<#@ assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.SqlServer.dll" #>
<#@ assembly name="%VS120COMNTOOLS%..\IDE\EntityFramework.SqlServerCompact.dll" #>

索性我发现这几个程序集确实没在编译报错的路径中,我直接 copy 粘贴到了指定的目录下甚至还在编译器中引用,编译依旧如此。有点棘手!

最后看了老外的分析,说是 visual studio 安装的环境变量值路径不对,后来才一愣发现真是这个问题

控制面板->系统->高级系统设置->高级->环境变量

最终才明白原来编译的路径依据是根据环境变量来的,真是图样图森破

 

转载于:https://www.cnblogs.com/byvar/p/4856556.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用以下命令启动这些 jar 包: ``` nohup java -jar codegen-service.jar > codegen-service.log & nohup java -jar data-market-service-integration.jar > data-market-service-integration.log & nohup java -jar data-market-service-mapping.jar > data-market-service-mapping.log & nohup java -jar data-market-service.jar > data-market-service.log & nohup java -jar data-masterdata-service.jar > data-masterdata-service.log & nohup java -jar data-metadata-service-console.jar > data-metadata-service-console.log & nohup java -jar data-metadata-service.jar > data-metadata-service.log & nohup java -jar data-quality-service.jar > data-quality-service.log & nohup java -jar data-standard-service.jar > data-standard-service.log & nohup java -jar data-visual-service.jar > data-visual-service.log & nohup java -jar datax-auth.jar > datax-auth.log & nohup java -jar datax-config.jar > datax-config.log & nohup java -jar datax-eureka.jar > datax-eureka.log & nohup java -jar datax-gateway.jar > datax-gateway.log & nohup java -jar datax-tool-monitor.jar > datax-tool-monitor.log & nohup java -jar email-service.jar > email-service.log & nohup java -jar file-service.jar > file-service.log & nohup java -jar quartz-service.jar > quartz-service.log & nohup java -jar system-service.jar > system-service.log & nohup java -jar workflow-service.jar > workflow-service.log & ``` 其中,`nohup` 命令可以使程序在后台运行,并将输出重定向到日志文件中。`&` 符号表示在后台运行该命令。请确保在执行此命令之前,已经安装了 Java 运行时环境,并且当前路径下存在相应的 jar 文件。如果 jar 文件不在当前路径下,可以使用绝对路径或相对路径指定文件的位置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值