Reputation: 157
I had an application which used the Asp.net Membership provider. I converted this project to EF4 and trying to use the same authentication.
I am using the old DB for my connection as
<add name="Entities1"
connectionString="metadata=res://*/DbContext.csdl|res://*/DbContext.ssdl|res://*/DbContext.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Master.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
<add name="PondsMasterEntities"
connectionString="metadata=res://*/DbContext.csdl|res://*/DbContext.ssdl|res://*/DbContext.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\PondsMaster.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
And now I am ending with this error.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist
on
var result = await UserManager.CreateAsync(user, model.Password);
But when I use like this. I can add delete entries from the DB.
private Entities1 db = new Entities1();
db.IssueMasterLogs.Add(log);
Any thoughts?
Upvotes: 0
Views: 342
Reputation: 1064
Looks like you're using a database first approach and an existing database for a project that uses ASP.Net Identity. By default, Identity (V2) works with a code first approach, creating it's required tables in the database. Usually, people end up having a separate connection string for Identity because of this (even though both connection strings point to the same database).
In your case, simply switching the DefaultConnection
Identity uses to your connection Entities1
will not help since it is not code first. You can however, keep the DefaultConnection
and modify it to point to your db, and keep using it code first. If you do this, you will have two connection strings (Entities1
and DefaultConnection
) that both point to the same database and are database first and code first, respectively.
For a db first a approach with Identity, you might want to take a look at this.
Upvotes: 2