0
votes

I have a azure V1 function using a project dll that handles entity framework. First I set connect string like

metadata=res://*/Dev.csdl|res://*/Dev.ssdl|res://*/Dev.msl;
provider=System.Data.SqlClient;
provider connection string='
data source={IP};initial catalog={DBName};
persist security info=True;
user id={User};password={PW};
MultipleActiveResultSets=True;
App=EntityFramework'

and I got

Keyword not supported: 'metadata'.

then I changed my connect string to

data source={IP};initial catalog={DBName};persist security info=True;user id={User};password={PW};

and I got

The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection. To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: http://go.microsoft.com/fwlink/?LinkId=394715

And here's my code

        DevEntities db = new DevEntities();

        var lstAcAccount = db.AcAccounts.ToList();

        return req.CreateResponse(HttpStatusCode.OK, lstAcAccount);

DevEntities is from other dll project that using the connect string above.

So, what should I do to make this work?

1
i would follow the suggestion in the error message. - Jazb

1 Answers

0
votes

You shouldn't use generated connection string, now you have all metadata files included in your solution. Instead try use in connection string section of app.config:

"data source=localhost\sqlexpress; initial catalog=sample; integrated security=True;MultipleActiveResultSets=True;"

If it is Database first:

Open the .edmx[Diagram] -> right click -> "Update Model from database"

And see if the will appear the "Add", "Refresh" and "Delete" tabs.

If doesn't... probably your connection is broken and the dialog for VS creates a new connection string will appear instead.

Hope it helps.