Error: "The underlying provider failed on Open" in Entity Framework application

Published Jan 15 2019 02:34 PM 30.4K Views
First published on MSDN on Aug 09, 2012

My name is Archana CM from Microsoft SQL Developer Support team, we support many data access technologies including Entity Framework, SSIS.

I had chance to work with developer who was having issues in his Entity Framework, one of the issue was while adding data to .mdf file which was on file system.

In today's blog I am sharing my experience on how we could resolve the issue for him and what issues he was facing.

It was Windows application and Entity Framework was used. As a backend SQLExpress was used in his application and he was saving data to .mdf file which was on file system.

When we executed the application and while trying to add data to .mdf file we could see below error message

Message: The underlying provider failed on Open.

Stack trace : at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)

at System.Data.EntityClient.EntityConnection.Open()

at System.Data.Objects.ObjectContext.EnsureConnection()

at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)

at System.Data.Objects.ObjectContext.SaveChanges()

at EFLenoard.DataMgr.AddFacility(String name, String address, String city) in D:\Research\EFParentChildInsert\EFParentChildInsert2010\DataMgr.cs:line 35

Inner Exception : InnerException = {"An attempt to attach an auto-named database for file D:\\Research\\EFParentChildInsert\\EFParentChildInsert2010\\bin\\Debug\\SplDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC shared …

Here is the connection string that was used, while issue was occurring.

<connectionStrings>

<add name="SQLDBEntities" connectionString="metadata=res://*/SplDBModel.csdl|res://*/SplDBModel.ssdl|res://*/SplDBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\SQLDB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

</connectionStrings>

In this case, Windows authentication with user instance was used to connect to SQL server which was mainly causing the issue.

In order to resolve the above issue, we had 2 solutions

Solution 1:

In the existing connection string to remove the “user Instance=true” and it works.

Probable cause of the issue could be as below:

  • The user instance cannot attach the database because the user does not have the required permissions. The user instance executes in the context of the user who opened the connection—not the normal SQL Server service account. The user who opened the user instance connection must have write permissions on the .mdf and .ldf files that are specified in the AttachDbFilename option of the connection string.
  • Another common issue is when you open a database file successfully when the database is attached to the SQL Server Express instance, but fails when you try to open it from the Visual Studio IDE. This might occur because the SQL Server Express instance is running as "NT AUTHORITY\NETWORK SERVICE," while the IDE is running as windows account. Therefore, the permissions may not work.

  • A variation of this issue is when the user that opens the user instance connection has read permissions on the database files but does not have write permissions. If you get a message saying that the database is opened as read only, you need to change the permissions on the database file.
  • The other main issue with user instances occurs because SQL Server opens database files with exclusive access. This is necessary because SQL Server manages the locking of the database data in its memory. Thus, if more than one SQL Server instance has the same file open, there is the potential for data corruption. If two different user instances use the same database file, one instance must close the file before the other instance can open it. There are two common ways to close database files, as follows.
    • User instance databases have the Auto Close option set so that if there are no connections to a database for 8-10 minutes, the database shuts down and the file is closed. This happens automatically, but it can take a while, especially if connection pooling is enabled for your connections.
    • Detaching the database from the instance by calling sp_detach_db will close the file. This is the method Visual Studio uses to ensure that the database file is closed when the IDE switches between user instances. For example, you are using the IDE to design a data-enabled Web page. You press F5 to run the application. The IDE detaches the database so that ASP.NET can open the database files. If you leave the database attached to the IDE and try to run the ASP page from your browser, ASP.NET cannot open the database because the file is still in use by the IDE.

Solution 2:

We created new connection to database with SQL Authentication as a workaround.

Thus connection string turns out to be as below.

<connectionStrings>

<add name="SQLDBEntities" connectionString="metadata=res://*/SplDBModel.csdl|res://*/SplDBModel.ssdl|res://*/SplDBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=D:\SQLDB.mdf;persist security info=True;

user id=saa;password=***;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

</connectionStrings>

Once applying either of these solutions, with below code we could save data to .mdf file which was on file system. By attached the .mdf file to SQL Server data can be confirmed.

public class DatatoMDFOnFileSystem

{

private SQLDBEntities _sqlDataContext = new SQLDBEntities();

private string _errorMessage;

public long AddDatatoMDFOnFileSystem(string name, string address, string city)

{

_errorMessage = String.Empty;

try

{

string connectString = ConfigurationManager.ConnectionStrings["SQLDBEntities"].ToString();

using (_sqlDataContext = new SQLDBEntities(connectString))

{

EFDatatoMDFOnFileSystem efDatatoMDFOnFileSystem = EFDatatoMDFOnFileSystem.CreateEFDatatoMDFOnFileSystem(0, name, address, city);

if (efDatatoMDFOnFileSystem != null)

{

_sqlDataContext.AddToEFDatatoMDFOnFileSystem(efDatatoMDFOnFileSystem);

_sqlDataContext.SaveChanges();

id = efDatatoMDFOnFileSystem.Id;

Console.WriteLine(String.Format("Record added with id, {0}.", id));

}

}

}

catch (Exception err)

{

_errorMessage = err.Message;

}

finally

{

Console.WriteLine("Error Message, {0}.", _errorMessage);

}

return id;

}

}

Happy Coding!!!!

Author : Archana , SQL Developer Engineer , Microsoft

Reviewed by : Snehadeep(MSFT), SQL Developer Technical Lead, Microsoft

%3CLINGO-SUB%20id%3D%22lingo-sub-317161%22%20slang%3D%22en-US%22%3EError%3A%20%22The%20underlying%20provider%20failed%20on%20Open%22%20in%20Entity%20Framework%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-317161%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Aug%2009%2C%202012%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EMy%20name%20is%20Archana%20CM%20from%20Microsoft%20SQL%20Developer%20Support%20team%2C%20we%20support%20many%20data%20access%20technologies%20including%20Entity%20Framework%2C%20SSIS.%3C%2FP%3E%0A%20%20%3CP%3EI%20had%20chance%20to%20work%20with%20developer%20who%20was%20having%20issues%20in%20his%20Entity%20Framework%2C%20one%20of%20the%20issue%20was%20while%20adding%20data%20to%20.mdf%20file%20which%20was%20on%20file%20system.%3C%2FP%3E%0A%20%20%3CP%3EIn%20today's%20blog%20I%20am%20sharing%20my%20experience%20on%20how%20we%20could%20resolve%20the%20issue%20for%20him%20and%20what%20issues%20he%20was%20facing.%3C%2FP%3E%0A%20%20%3CP%3EIt%20was%20Windows%20application%20and%20Entity%20Framework%20was%20used.%20As%20a%20backend%20SQLExpress%20was%20used%20in%20his%20application%20and%20he%20was%20saving%20data%20to%20.mdf%20file%20which%20was%20on%20file%20system.%3C%2FP%3E%0A%20%20%3CP%3EWhen%20we%20executed%20the%20application%20and%20while%20trying%20to%20add%20data%20to%20.mdf%20file%20we%20could%20see%20below%20error%20message%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EMessage%3A%20The%20underlying%20provider%20failed%20on%20Open.%3C%2FP%3E%0A%20%20%3CP%3EStack%20trace%20%3A%20at%20System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean%20openCondition%2C%20DbConnection%20storeConnectionToOpen%2C%20DbConnection%20originalConnection%2C%20String%20exceptionCode%2C%20String%20attemptedOperation%2C%20Boolean%26amp%3B%20closeStoreConnectionOnFailure)%3C%2FP%3E%0A%20%20%3CP%3Eat%20System.Data.EntityClient.EntityConnection.Open()%3C%2FP%3E%0A%20%20%3CP%3Eat%20System.Data.Objects.ObjectContext.EnsureConnection()%3C%2FP%3E%0A%20%20%3CP%3Eat%20System.Data.Objects.ObjectContext.SaveChanges(SaveOptions%20options)%3C%2FP%3E%0A%20%20%3CP%3Eat%20System.Data.Objects.ObjectContext.SaveChanges()%3C%2FP%3E%0A%20%20%3CP%3Eat%20EFLenoard.DataMgr.AddFacility(String%20name%2C%20String%20address%2C%20String%20city)%20in%20D%3A%5CResearch%5CEFParentChildInsert%5CEFParentChildInsert2010%5CDataMgr.cs%3Aline%2035%3C%2FP%3E%0A%20%20%3CP%3EInner%20Exception%20%3A%20InnerException%20%3D%20%7B%22An%20attempt%20to%20attach%20an%20auto-named%20database%20for%20file%20D%3A%5C%5CResearch%5C%5CEFParentChildInsert%5C%5CEFParentChildInsert2010%5C%5Cbin%5C%5CDebug%5C%5CSplDB.mdf%20failed.%20A%20database%20with%20the%20same%20name%20exists%2C%20or%20specified%20file%20cannot%20be%20opened%2C%20or%20it%20is%20located%20on%20UNC%20shared%20%E2%80%A6%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EHere%20is%20the%20connection%20string%20that%20was%20used%2C%20while%20issue%20was%20occurring.%3C%2FP%3E%0A%20%20%3CP%3E%3CCONNECTIONSTRINGS%3E%3C%2FCONNECTIONSTRINGS%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CADD%20name%3D%22%26quot%3BSQLDBEntities%26quot%3B%22%20connectionstring%3D%22%26quot%3Bmetadata%3Dres%3A%2F%2F*%2FSplDBModel.csdl%7Cres%3A%2F%2F*%2FSplDBModel.ssdl%7Cres%3A%2F%2F*%2FSplDBModel.msl%3Bprovider%3DSystem.Data.SqlClient%3Bprovider%22%20connection%3D%22%22%20string%3D%22%26amp%3Bquot%3Bdata%22%20source%3D%22.%5CSQLEXPRESS%3Battachdbfilename%3D%7CDataDirectory%7C%5CSQLDB.mdf%3Bintegrated%22%20security%3D%22True%3Buser%22%20instance%3D%22True%3Bmultipleactiveresultsets%3DTrue%3BApp%3DEntityFramework%26amp%3Bquot%3B%26quot%3B%22%20providername%3D%22%26quot%3BSystem.Data.EntityClient%26quot%3B%22%3E%3C%2FADD%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EIn%20this%20case%2C%20Windows%20authentication%20with%20user%20instance%20was%20used%20to%20connect%20to%20SQL%20server%20which%20was%20mainly%20causing%20the%20issue.%3C%2FP%3E%0A%20%20%3CP%3EIn%20order%20to%20resolve%20the%20above%20issue%2C%20we%20had%202%20solutions%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20Solution%201%3A%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EIn%20the%20existing%20connection%20string%20to%20remove%20the%20%3CB%3E%20%E2%80%9Cuser%20Instance%3Dtrue%E2%80%9D%20%3C%2FB%3E%20and%20it%20works.%3C%2FP%3E%0A%20%20%3CP%3EProbable%20cause%20of%20the%20issue%20could%20be%20as%20below%3A%3C%2FP%3E%0A%20%20%3CUL%3E%0A%20%20%20%3CLI%3E%3CEM%3E%20The%20user%20instance%20cannot%20attach%20the%20database%20because%20the%20user%20does%20not%20have%20the%20required%20permissions.%20The%20user%20instance%20executes%20in%20the%20context%20of%20the%20user%20who%20opened%20the%20connection%E2%80%94not%20the%20normal%20SQL%20Server%20service%20account.%20The%20user%20who%20opened%20the%20user%20instance%20connection%20must%20have%20write%20permissions%20on%20the%20.mdf%20and%20.ldf%20files%20that%20are%20specified%20in%20the%20AttachDbFilename%20option%20of%20the%20connection%20string.%20%3C%2FEM%3E%20%3CEM%3E%20%3C%2FEM%3E%3C%2FLI%3E%0A%20%20%3C%2FUL%3E%0A%20%20%3CUL%3E%0A%20%20%20%3CLI%3E%3CEM%3E%20Another%20common%20issue%20is%20when%20you%20open%20a%20database%20file%20successfully%20when%20the%20database%20is%20attached%20to%20the%20SQL%20Server%20Express%20instance%2C%20but%20fails%20when%20you%20try%20to%20open%20it%20from%20the%20Visual%20Studio%20IDE.%20This%20might%20occur%20because%20the%20SQL%20Server%20Express%20instance%20is%20running%20as%20%22NT%20AUTHORITY%5CNETWORK%20SERVICE%2C%22%20while%20the%20IDE%20is%20running%20as%20windows%20account.%20Therefore%2C%20the%20permissions%20may%20not%20work.%20%3C%2FEM%3E%20%3CEM%3E%20%3C%2FEM%3E%3C%2FLI%3E%0A%20%20%3C%2FUL%3E%0A%20%20%3CP%3E%3CEM%3E%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CUL%3E%0A%20%20%20%3CLI%3E%3CEM%3E%20A%20variation%20of%20this%20issue%20is%20when%20the%20user%20that%20opens%20the%20user%20instance%20connection%20has%20read%20permissions%20on%20the%20database%20files%20but%20does%20not%20have%20write%20permissions.%20If%20you%20get%20a%20message%20saying%20that%20the%20database%20is%20opened%20as%20read%20only%2C%20you%20need%20to%20change%20the%20permissions%20on%20the%20database%20file.%20%3C%2FEM%3E%3C%2FLI%3E%0A%20%20%3C%2FUL%3E%0A%20%20%3CUL%3E%0A%20%20%20%3CLI%3E%3CEM%3E%20The%20other%20main%20issue%20with%20user%20instances%20occurs%20because%20SQL%20Server%20opens%20database%20files%20with%20exclusive%20access.%20This%20is%20necessary%20because%20SQL%20Server%20manages%20the%20locking%20of%20the%20database%20data%20in%20its%20memory.%20Thus%2C%20if%20more%20than%20one%20SQL%20Server%20instance%20has%20the%20same%20file%20open%2C%20there%20is%20the%20potential%20for%20data%20corruption.%20If%20two%20different%20user%20instances%20use%20the%20same%20database%20file%2C%20one%20instance%20must%20close%20the%20file%20before%20the%20other%20instance%20can%20open%20it.%20There%20are%20two%20common%20ways%20to%20close%20database%20files%2C%20as%20follows.%20%3C%2FEM%3E%3CUL%3E%0A%20%20%20%20%20%3CLI%3E%3CEM%3EUser%20instance%20databases%20have%20the%20%3C%2FEM%3E%20%3CSTRONG%3E%20Auto%20Close%20%3C%2FSTRONG%3E%20%3CEM%3E%20option%20set%20so%20that%20if%20there%20are%20no%20connections%20to%20a%20database%20for%208-10%20minutes%2C%20the%20database%20shuts%20down%20and%20the%20file%20is%20closed.%20This%20happens%20automatically%2C%20but%20it%20can%20take%20a%20while%2C%20especially%20if%20connection%20pooling%20is%20enabled%20for%20your%20connections.%20%3C%2FEM%3E%3C%2FLI%3E%0A%20%20%20%20%20%3CLI%3E%3CEM%3EDetaching%20the%20database%20from%20the%20instance%20by%20calling%20%3C%2FEM%3E%20%3CSTRONG%3E%20sp_detach_db%20%3C%2FSTRONG%3E%20%3CEM%3E%20will%20close%20the%20file.%20This%20is%20the%20method%20Visual%20Studio%20uses%20to%20ensure%20that%20the%20database%20file%20is%20closed%20when%20the%20IDE%20switches%20between%20user%20instances.%20For%20example%2C%20you%20are%20using%20the%20IDE%20to%20design%20a%20data-enabled%20Web%20page.%20You%20press%20F5%20to%20run%20the%20application.%20The%20IDE%20detaches%20the%20database%20so%20that%20ASP.NET%20can%20open%20the%20database%20files.%20If%20you%20leave%20the%20database%20attached%20to%20the%20IDE%20and%20try%20to%20run%20the%20ASP%20page%20from%20your%20browser%2C%20ASP.NET%20cannot%20open%20the%20database%20because%20the%20file%20is%20still%20in%20use%20by%20the%20IDE.%20%3C%2FEM%3E%3C%2FLI%3E%0A%20%20%20%20%3C%2FUL%3E%0A%20%20%20%3C%2FLI%3E%0A%20%20%3C%2FUL%3E%0A%20%20%3CP%3E%3CB%3E%20Solution%202%3A%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EWe%20created%20new%20connection%20to%20database%20with%20SQL%20Authentication%20as%20a%20workaround.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67198i87DED373BB76BAD8%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThus%20connection%20string%20turns%20out%20to%20be%20as%20below.%3C%2FP%3E%0A%20%20%3CP%3E%3CCONNECTIONSTRINGS%3E%3C%2FCONNECTIONSTRINGS%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CADD%20name%3D%22%26quot%3BSQLDBEntities%26quot%3B%22%20connectionstring%3D%22%26quot%3Bmetadata%3Dres%3A%2F%2F*%2FSplDBModel.csdl%7Cres%3A%2F%2F*%2FSplDBModel.ssdl%7Cres%3A%2F%2F*%2FSplDBModel.msl%3Bprovider%3DSystem.Data.SqlClient%3Bprovider%22%20connection%3D%22%22%20string%3D%22%26amp%3Bquot%3Bdata%22%20source%3D%22.%5CSQLEXPRESS%3Battachdbfilename%3DD%3A%5CSQLDB.mdf%3Bpersist%22%20security%3D%22%22%20info%3D%22True%3B%26lt%3B%2FP%22%3E%0A%20%20%3C%2FADD%3E%3C%2FP%3E%3CP%3Euser%20id%3Dsaa%3Bpassword%3D***%3Bmultipleactiveresultsets%3DTrue%3BApp%3DEntityFramework%26amp%3Bquot%3B%22%20providerName%3D%22System.Data.EntityClient%22%20%2F%26gt%3B%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EOnce%20applying%20either%20of%20these%20solutions%2C%20with%20below%20code%20we%20could%20save%20data%20to%20.mdf%20file%20which%20was%20on%20file%20system.%20By%20attached%20the%20.mdf%20file%20to%20SQL%20Server%20data%20can%20be%20confirmed.%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20public%20class%20DatatoMDFOnFileSystem%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20private%20SQLDBEntities%20_sqlDataContext%20%3D%20new%20SQLDBEntities()%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20private%20string%20_errorMessage%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20public%20long%20AddDatatoMDFOnFileSystem(string%20name%2C%20string%20address%2C%20string%20city)%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20_errorMessage%20%3D%20String.Empty%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20try%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20string%20connectString%20%3D%20ConfigurationManager.ConnectionStrings%5B%22SQLDBEntities%22%5D.ToString()%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20using%20(_sqlDataContext%20%3D%20new%20SQLDBEntities(connectString))%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20EFDatatoMDFOnFileSystem%20efDatatoMDFOnFileSystem%20%3D%20EFDatatoMDFOnFileSystem.CreateEFDatatoMDFOnFileSystem(0%2C%20name%2C%20address%2C%20city)%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20if%20(efDatatoMDFOnFileSystem%20!%3D%20null)%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20_sqlDataContext.AddToEFDatatoMDFOnFileSystem(efDatatoMDFOnFileSystem)%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20_sqlDataContext.SaveChanges()%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20id%20%3D%20efDatatoMDFOnFileSystem.Id%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20Console.WriteLine(String.Format(%22Record%20added%20with%20id%2C%20%7B0%7D.%22%2C%20id))%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20catch%20(Exception%20err)%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20_errorMessage%20%3D%20err.Message%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20finally%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20Console.WriteLine(%22Error%20Message%2C%20%7B0%7D.%22%2C%20_errorMessage)%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20return%20id%3B%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CEM%3E%20%7D%20%3C%2FEM%3E%3C%2FP%3E%0A%20%20%3CP%3EHappy%20Coding!!!!%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CSTRONG%3E%20Author%20%3A%20Archana%20%2C%20SQL%20Developer%20Engineer%20%2C%20Microsoft%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CSTRONG%3E%20Reviewed%20by%20%3A%20Snehadeep(MSFT)%2C%20SQL%20Developer%20Technical%20Lead%2C%20Microsoft%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%20%0A%3CLINGO-TEASER%20id%3D%22lingo-teaser-317161%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Aug%2009%2C%202012%20My%20name%20is%20Archana%20CM%20from%20Microsoft%20SQL%20Developer%20Support%20team%2C%20we%20support%20many%20data%20access%20technologies%20including%20Entity%20Framework%2C%20SSIS.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-317161%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOLEDB%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Jan 15 2019 02:34 PM
Updated by: