7

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" />

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

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..

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?

/Edit:

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.` 

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

Community
  • 1
  • 1
user2609980
  • 10,264
  • 15
  • 74
  • 143
  • 5
    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. – user3038092 Dec 02 '13 at 14:53
  • Okay that explains a lot! So I have to use the provider connection string. I'll try and report back. /Edit Okay I changed it. -> Now it says the "Data source" keyword is not supported. – user2609980 Dec 02 '13 at 14:55
  • @user3038092 How should I refer to the connection string with regard to the `'Data source is not supported'` error? Is it even possible? Please note that this connection string is in my Test project. Not in the real project, there the string does work. – user2609980 Dec 02 '13 at 15:19
  • 1
    Replace Data Source with `Server`. http://stackoverflow.com/questions/19314320/the-data-source-keyword-is-not-supported-asp-net-app-entity-framework-5-co – user3038092 Dec 02 '13 at 15:46
  • Thanks. Now I get this error: `Test Outcome: Failed error 0040: The Type date is not qualified with a namespace or alias. Only primitive types can be used without qualification.` Very strange, since I use `[DataType(DataType.DateTime)]` everywhere. – user2609980 Dec 02 '13 at 15:53

1 Answers1

1

As user3038092 explained:

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.

Community
  • 1
  • 1
user2609980
  • 10,264
  • 15
  • 74
  • 143
  • 3
    Give the link of the question, not the user. – Altaf Patel Jul 08 '15 at 07:11
  • 1
    @AltafPatel It is the first comment underneath the question above. – user2609980 Jul 12 '15 at 21:12
  • I do not see the comment now, can you tag the question not the user? – ransems Nov 13 '18 at 11:36
  • 1
    @ransems Like I said it is the first comment underneath [THIS question](https://stackoverflow.com/questions/20331107/where-to-find-csdl-ssdl-and-msl-files-in-entity-framework-4-0-code-first/20374520). I copied the content of the comment into this answer if it ever disappears. I don't know how to link to a comment. – user2609980 Nov 13 '18 at 14:28