c# - Get data from local DB not working -
I have created an MVC5 application and I have a local DB, currently I have entered the data in the table and I see it Server Explorer - & gt; MDF file under the data connection, now I want to read it down through the API and not working, I have provided the ID to me in the table and I get zero, I think I need to provide The connection string for the API, but it's not sure how to do this? This is a DB reference from model definition public> PersonModelDbContext {public personModelDBContax (): Base ("Connection 1") {} This is the read API This connection string is the web conefig file Update - Apart from this I try with the following without success, I get an error: A type of exception was 'System.Data.DataException' in EntityFramework.dll but was not handled in user code Additional information: An exception When starting the database, see Inner Expansion for details. You can try to set your connection string in this format because it Local You can try not to set the connection to
Private personModelDBContact db = New PersonModelDbContext (); Public Person GetPrviderData (String ID) {Person Person = db.Person.Find (ID); Return person; }
db.Database.Connection.ConnectionString = @ "Data Source = (LocalBible) \ v11.0; Attached DiffFillName = | Data Directory | \ PersonMDF; Initial Catalog = Individuals; Integrated Security = True";
& lt; Add name = "database connection connection" connection sting = "data source = [server namehead]; user id = [database ogonid / perhaps] password = [database password]; initial catalog = the envelope hello db;" provider name = "System.Data.SqlClient "/>
[brackets] in the connection string.
Comments
Post a Comment