We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Syncfusion, MySQL and Entity Framework

Dear Syncfusion Gurus,
 
Good morning.
 
I would just like to ask if anyone has already tried using Syncfusion with Entity Framework and MySQL as the database?
 
Hope someone can point me out on how to implement such combination and has successfuly manage to incorporate them all. :)
 
Thanks in advance.
 
regards,
almond

15 Replies

SS Satheeskumar S Syncfusion Team July 2, 2013 09:49 AM UTC

Hi Almond,

 


Thanks for your interest in Syncfusion Products.

 

We glad to inform you that your requirement [Entity Framework with MySQL Database] can be achieved using below steps.

 

[Add Entity Data Model]

1. In Models Add ADO.Net Entity Data Model

2. In the ADO.Net Entity Data Model Wizard add edmx file.

3. Select Generate from Database and click the New Connection.

4. Select MySQL Database and give the authorization information and select the database from MySQL.

 

For your convenience we have attached a sample. Could you please refer this sample and get back to us if you have any other queries.

 

Let us know if you have any other concerns.

 

 

Regards,

Satheeskumar S



MySqlMVC3_f352e39d.zip


AR Almond R. M. Monteagudo July 3, 2013 09:23 AM UTC

Hi Satheeskumar,

Much thanks for your immediate response, I have already successfully implemented your example.  What i am having a hard time is when I implement  CRUD with MySQL particularly when I want to use a Dialog Template Edit Mode in JSON mode.

I hope someone can point me out on how to go about it.

Again, thanks in advance for the response.

regards,
almond


SS Satheeskumar S Syncfusion Team July 4, 2013 11:23 AM UTC

Hi Almond,

 

Thanks for your interest in Syncfusion Products.

 

We have modified the sample as per your requirement to achieve “CRUD Operations with MySQL in Dialog Template Mode”. To achieve this we have changed the following things in the sample.

 

Please refer the below Steps to achieve Dialog Template Mode in JSON.

·       Set the ActionMode to JSON.

·       Set the Editing Properties.

·       Set the EditMode to DialogTemplate.

·       Call the Template file using DialogModeEditorTemplate.

 

Please refer the below code snippet for CRUD Operation.

 

[CSHTML]

//Enable the Dialog Editor Template

.Editing(edit =>

{

           edit.EditMode(GridEditMode.DialogTemplate);

           edit.DialogModeEditorTemplate("OrderEditorTemplate");

            

})

 

[Controller]

public ActionResult Index()

{

            var data = new worldEntities1().cities.OrderBy(c => c.ID).ToList();

            return View(data);

}

 

[AcceptVerbs(HttpVerbs.Post)]

public ActionResult Index(PagingParams args)

{

            IEnumerable data = new worldEntities1().cities.OrderBy(c => c.ID).ToList();

            return data.GridJSONActions<city>();

}

 

For your convenience we have attached a sample. Could you please use this sample and get back to us if you have any other queries.

 

Let us know if you have any other concerns.

 

 

Regards,

Satheeskumar S



MySqlCRUD_69ca7d30.zip


AR Almond R. M. Monteagudo July 30, 2013 12:09 AM UTC

Dear Satheeskumar S,

Good morning. Much thanks for the sample.  After a much checking of the codes, I finally had success in running the codes including the images :)  

I am actually trying to look on how to implement validation using EF without the models.  Most of the  samples that I have seen implements the models and create their validation there. I would like to like to ask if someone can point me out where can i implement the validation.  Can i do it on the .edmx file of the project?

Thanks in advance for your reply, Syncfusion Gurus. :)



SS Satheeskumar S Syncfusion Team July 30, 2013 10:44 AM UTC

Hi Almond,

 

Thanks for your interest in Syncfusion Products.


If you want to perform validation in edmx file, this is not good for all cases because at the time of database modification, we need to update the edmx file. In that time the edmx file was refreshed. So the validation codes which are written inside the edmx file was cleared.

So we suggest you use MetadataType for validation. We have to refer the MetadataType to the class file (“city.cs”) which is placed inside the edmx file. Then we have to write the class file for validation (“CityMetaData.cs”). We have to refer few script files for validation.


Please refer the below code snippet.

[cshtml]

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"> </script>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript">

</script>

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>  

 

[city.cs]

[MetadataType(typeof(CityMetadata))] //CityMetadata is a class file for validation

public partial class city{

      …..

}

 

[CityMetaData.cs]                                                           

public class CityMetaData

{

        public int ID { get; set; }

        [RegularExpression(@"[A-Za-z]*$", ErrorMessage = "Name must be string")]

        [StringLength(15, ErrorMessage = "Name must be 15 characters.")]

        public string Name { get; set; }

        [RegularExpression(@"[A-Za-z]*$", ErrorMessage = "Country Code must be string")]

        [StringLength(15, ErrorMessage = "Country Code must be 5 characters.")]

        public string CountryCode { get; set; }

        [RegularExpression(@"[A-Za-z]*$", ErrorMessage = "District must be string")]

        [StringLength(15, ErrorMessage = "District must be 15 characters.")]

        [Required]

        public string District { get; set; }

        public int Population { get; set; }

}

For your convenience we have attached a sample. Could you please refer this sample and get back to us if you have any queries.


Please Let us know if you have any other concerns.

 

Regards,

Satheeskumar S



MySqlCRUD_478bc653.zip


AR Almond R. M. Monteagudo July 31, 2013 03:07 AM UTC

Much thanks for the the immediate response.

I'll try and check the attached file and implement it based on my sample and will revert to you the results.

Thanks again :)

 



AR Almond R. M. Monteagudo August 1, 2013 12:24 AM UTC

Hi Satheeskumar,

Again I would like to say thanks as i have successfully implemented the Validation by creating a metadata class.  I just have one inquiry, is there anyway to have the error message on a certain area in the edit template?  The error message string that i want to display appears under the text box in the next row.  Does it have any thing to do with my edit template layout?  Please see my edit template codes below:

    <div id="Head">
        <table class="table-container">
            <tr>
                <td>
                    <table class="content-left">
                        <tr>
                            <td></td>
                            <td>
                                @Html.TextBoxFor(model => model.branch_idno, new { @class = "hidden" })
                            </td>
                        </tr>
                        <tr>
                            <td>Code:
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.branch_code)
                                @Html.ValidationMessageFor(model => model.branch_code)
                            </td>
                        </tr>
                        <tr>
                            <td>Description:
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.branch_chapel_desc)
                            </td>
                        </tr>
                        <tr>
                            <td>Address:
                            </td>
                            <td>@Html.TextAreaFor(model => model.branch_address, 3, 2, new { style = "width: 150px;" })
                            </td>
                        </tr>
                        <tr>
                            <td>Location:
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.branch_location)
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <table class="content-right">
                        <tr>
                            <td>Contact No:</td>
                            <td>
                                @Html.TextBoxFor(model => model.branch_contactno)
                                @Html.ValidationMessageFor(model => model.branch_contactno)
                            </td>
                        </tr>
                        <tr>
                            <td>Contact Person:</td>
                            <td>@Html.TextBoxFor(model => model.branch_contactperson) </td>
                        </tr>
                        <tr>
                            <td>Email:
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.branch_email)
                                @Html.ValidationMessageFor(model => model.branch_email)
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">Map:
                </td>
            </tr>
        </table>
    </div>

Hope someone can point me out on how to go about on how to place the error message in another location in my Edit Template.

Thanks in advance Syncfusion Gurus :)

regards,
almond


HJ Hariharan J V Syncfusion Team August 5, 2013 09:19 AM UTC

Hi Almond,

Sorry for the delay.

We glad to inform that we have achieved your requirement("displaying validation error message next row of the textbox"). We have added the Validation error message inside the new 'tr' to achieve this. Please refer the below code snippets.

[OrderEditorTemplate.cshtml]
@model MySqlCRUD.Models.city
@Html.ValidationSummary(true)
<fieldset>
<b>Order Details</b>
<table class="table-container">
<tr style="height:20px;">
<td>
ID
</td>
<td>
@Html.TextBoxFor(model => model.ID)
</td>
</tr>
<tr style="height:20px;padding-left:20px;">
<td></td>
<td style="padding-right:20px;">
@Html.ValidationMessageFor(model => model.ID)
</td>
</tr>
-----------
-----------
</table>
</fieldset>

For your convenience, we have modified the above given sample and the same can be downloaded from the below link.

Sample: MySqlCRUD.zip


Please let us know if you have any other concerns.

Regards,
Hariharan J.V.



AR Almond R. M. Monteagudo August 22, 2013 11:45 PM UTC

Hello Hariharan J.V.,

Good morning.

Much thanks once again for your help. I have successfully implemented the validation with the code that you sent.

I would just like to ask if by chance Syncfusion has the feature to have the validation message something like tool tip, instead that the message is inside another <td> so that it won't adjust the the layout of the form.

Thanks again in advance for all the help from the Syncfusion Gurus :)

regards,
almond


HJ Hariharan J V Syncfusion Team August 26, 2013 02:07 PM UTC

Hi Almond,

Thanks for your update.

We are working on this and we will update you on two business days(August 28,2013).

Please let us know if you have any concerns.

Regards,
Hariharan J.V.


AR Almond R. M. Monteagudo August 27, 2013 02:11 AM UTC

much thanks for your immediate update.

This forum is indeed one of the best forum I have joined.

We'll wait for your updates.

regards,
almond


SS Satheeskumar S Syncfusion Team August 28, 2013 12:56 PM UTC

Hi Almond,

 

Thanks for your patience.


We glad to inform that we have achieved your requirement ("displaying validation error in tooltip"). We have modified the above given sample earlier to achieve your requirement. We have added CSS file (“Validate.css”) and tooltip image (“Validation.png”) to the content folder for displaying the validation message in tooltip.

Please refer the below code snippets.

[Validate.css]

.field-validation-error{

            background: transparent url("Content/Validation.png") no-repeat scroll;

            margin-left: -33px;

            margin-top: -20px;

            padding: 20px 12px 22px 12px;

            position: absolute;

            width: 250px;

            text-align: left;

            vertical-align: middle;

            color:Red;

}

 

[layout.shtml]

@(Html.Syncfusion().StyleManager().Combine(true).Minify(true)

.Register(component =>{

                component.Add(ComponentType.Grid);

                component.Add("~/Content/validate.css");           

})

)

For your convenience we have attached the sample. Could you please use this sample and get back to us if you have any queries.

Sample- MySqlCRUD.zip

Please let us know if you have any other concerns.

 

Regards,

Satheeskumar S

 



AR Almond R. M. Monteagudo August 28, 2013 03:54 PM UTC

Hello Satheeskumar S,

Again, much thanks for the quick response and the sample. We'll test it and then send you some feedback.

Loving this Syncfusion and this forum more and more... 

regards,
almond :)


AR Almond R. M. Monteagudo August 30, 2013 12:02 AM UTC

Thank you so much again.

I already had it working. Initially I wasn't able to show the message just founding out that i forgot to declare the metadata file of the table and once i declared it...I had the error message working.

Thanks again for all the help and till next time.  Hoping that this forum will continue to help beginners like us.

again two thumbs up for this forum and its members :)

regards,
almond


HJ Hariharan J V Syncfusion Team August 30, 2013 12:43 PM UTC

Hi Almond,

Thanks for your update.

We are glad to know that your issue has been resolved. Please let us know if you have any other concerns so that we will be happy to help you out.

Regards,
Hariharan J.V.


Loader.
Up arrow icon