Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Unassigned: CodeFirst - The underlying provider failed on Open. [1219]

$
0
0
Hello,

I wrote a code first application in Entity Framework 5 and the communication between the application and database worked fine.
I switched Entity Framework to [EntityFramework 6.0.0-alpha3](http://nuget.org/packages/EntityFramework/6.0.0-alpha3) and it still worked fine. Then I switched it to [EntityFramework 6.0.0-beta1](http://nuget.org/packages/EntityFramework/6.0.0-beta1) and I have a problem.

Code:
```
using (MyContext db = new MyContext())
{
db.Countries.Add(new Country { Name = "England" });
db.SaveChanges();
}
```
The line db.SaveChanges(); throws an exception, database is not created.

Exception Messages:
- The underlying provider failed on Open.
- Cannot open database \"DatabaseName\" requested by the login. The login failed.\r\nLogin failed for user 'UserName'.

Working connection strings I used in EF5 and EF6 Alpha3:

```
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=MJAN\SQLSERVER; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
```

```
<connectionStrings>
<add name="MyContext" connectionString="data source=MJAN\SQLSERVER;integrated security=True;initial catalog=MyCodeFirstDB" providerName="System.Data.SqlClient"/>
</connectionStrings>
```

Can you tell me why did it stop working and what should l change to fix it? Maybe I shall create a connection string in the other way that it used to work?
Comments: https://entityframework.codeplex.com/workitem/1156

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>