.net core to sqlserverce issue

Posted by Mokkarasu under ASP.NET Core on 2/16/2018 | Points: 10 | Views : 208 | Status : [Member] | Replies : 0
Am trying to connect sqlserverce(.sdf) file using .net core console. But am keep on getting the below error. Whereas the same code working properly in .net framework. Can any one suggest me what is the issue.

The type initializer for 'System.Data.SqlServerCe.KillBitHelper' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Permissions

Below is my code, as soon as the debugger enter sqlceconnection it is throwing the above error.

string constring = @"Data Source = C:\Test.sdf";
SqlCeConnection conn = new SqlCeConnection(constring);
DataTable dTable = new DataTable();
SqlCeCommand cmd = new SqlCeCommand("SELECT [Type],[Key],[Data] FROM table", conn);
SqlCeDataAdapter dAdapter = new SqlCeDataAdapter(cmd);


(No response found.)

Login to post response