0

I am new with the entity framework. I have a dashboard with widgets and this is my table in Microsoft SQL server. Table

The reason I have widgets as a blob and not as a seperated entity is because I am not gonna query on the widgets table. Only data like SELECT * FROM Dashboard WHERE dashboardid =x

This is my DashboardDAL class:

public class DashboardDAL
{
    public Dashboard GetDashboardPerUser()
    {
        throw new NotImplementedException();
    }

    public string AddWidget()
    {
        throw new NotImplementedException();
    }
}

I want to add a widget with the entity framework. A Json object of a widget looks like this:

{name:"Weather", dashboardid:"2", userID:"4", "x":1,"y":0,"width":3,"height":1}

How can I add a widget object and save it as a BLOB in the database?

Kind regards

1 Answer 1

3

JSON is a string. Use a string property on an entity to store it with EF. This will map to a NVARCHAR(MAX) column in SQL Server, which is the correct type for storing JSON in SQL Server.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! This did the trick and I changed the datatype of widgets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.