How to add new tables in DB and access its data using Linq

150 views
Skip to first unread message

chaha...@gmail.com

unread,
Nov 22, 2016, 2:31:46 AM11/22/16
to KalikoCMS Developer Forum
HiFredrik,


If I need to create few new table/SP in current db how can that be done? And again how will I access those using Linq. As till all I could save in DB was in form of Page model that too using kaliko cms predefined methods. Now if I need to add some additional data, which is master data and for which I dont need admin pages to submit.

I tried adding another class library of DB First context for the same DB but on use it gives following error:

"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"

Kindly help, how can I achieve this?


Thanks
Chanchal

Fredrik Schultz

unread,
Nov 24, 2016, 2:32:30 PM11/24/16
to KalikoCMS Developer Forum
Depending on what type of information you want to store you might want to look at http://kaliko.com/cms/get-started/data-store/ which offers a built-in object store. But for adding relational data a separate solution is a better choice.

As long as the new context doesn't interfere with the CMS-related tables I don't see any problem in this approach. The ASP.NET Identity implementation made for the CMS uses this approach (although with Telerik's Data Access instead of Entity Framework).

As I'm more familiar with using the code-first approach I'm not that knowledgeable with the database first approach, but the error you receive looks like it's related to not finding the connection string, do you have the connection string in the web.config for the web project in your solution (matching the name used when creating the model)?
Reply all
Reply to author
Forward
0 new messages