首先在哪里可以找到Entity Framework 4.0代码中的.csdl,.ssdl和.msl文件? [英] Where to find .csdl, .ssdl, and .msl files in Entity Framework 4.0 code first?

查看:128
本文介绍了首先在哪里可以找到Entity Framework 4.0代码中的.csdl,.ssdl和.msl文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尽力运行测试,并且需要指定一个连接字符串,其中还包含对 .csdl, .ssdl的引用 .msl 文件。 (无效)连接字符串现在看起来像这样:

I want to run tests with Effort and to do that I need to specify a connectionstring that also contains a reference to .csdl, .ssdl, and .msl files. The (non-working) connectionstring looks like this now:

<add name="SQLAzureConnection" connectionString=
 "metadata=res://*/Model.projectContext.csdl|
res://*/Model.projectContext.ssdl|res://*/Model.projectContext.msl;
  provider=System.Data.SqlClient;
  provider connection string=&quot;Data Source=(LocalDb)\v11.0;Initial Catalog=Database_Nieuw;Integrated Security=false;MultipleActiveResultSets=False&quot;"
 providerName="System.Data.EntityClient" />

Model.projectContext 部分是错误的,但我不知道应该是什么。

The Model.projectContext part are wrong but I do not know what it should be.

当我使用此字符串时,在使用该连接字符串通过Effort建立模拟数据库连接的测试中,出现以下错误。

When I use this string I get the following error on a test that uses this connectionstring to make a mock database connection with Effort.

Test: failed
Result Message: Initialization method  
project.Tests.Controllers.ShoppingCartTest.Initialize threw exception. 
System.InvalidOperationException: System.InvalidOperationException: Resource res://*
/Model.seashell_brawl_corveeContext.csdl not found..

我不知道在哪里可以找到此 .csdl 文件,我只知道这是必要的。我无法从我的 .emdx 文件创建它们,因为我有一个代码优先数据库,并且在设计器中单击鼠标右键不提供 Update from from the database的选项。模型作为另一个问题作为解决方案。我还设置了元数据工件处理

I have no idea where I can find this .csdl file, I only know it is necessary. I cannot create them from my .emdx file because I have a code first database, and right clicking in designer does not give the option to Update database from model as another question gave as a solution. I also set the Metadata Artifact Processing" option to "Embed in Output Assembly.

有人知道我在哪里可以找到这些文件以及如何正确引用它们吗?

Does anyone know where I can find these files and how I can reference them correctly?

/编辑:

对我来说,现在很清楚,文件不在代码优先项目中。通过使用下面注释中的user20 ...的提示,连接字符串现在似乎可以工作了。下面是一个新问题:

Alright, it is clear to me now that the files do not exist in code first projects. By using the tip of user20... below in the comments the connection string seems to work now. A new issue is the following:

`Test Outcome:  Failed  error 0040: The Type date is not qualified with a namespace or 
alias. Only primitive types can be used without qualification.` 

非常奇怪,因为我使用的是 [DataType(DataType.DateTime)] 随处可见。有人知道如何解决吗?

Very strange, since I use [DataType(DataType.DateTime)] everywhere. Does anyone know how to solve this?

推荐答案

用户3038092 解释:


使用代码优先功能时,您没有.csdl,.ssdl和.msl 。
连接字符串也有所不同。基本上正确的连接
字符串就是您当前连接字符串
中的提供者连接字符串

When using Code First you do not have a .csdl, .ssdl and .msl. The connection string differs also. Basically the correct connection string is what is described as "provider connection string" within your current connection string



that solves the problem.

这篇关于首先在哪里可以找到Entity Framework 4.0代码中的.csdl,.ssdl和.msl文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆