I am creating an MVC 6 project and I would prefer to use Classic ADO.net over Entity Framework 7. However, it says that the namespace cannot be found for both the DataTable and the SqlDataAdapter . I have a System.Data and System.Data.SqlClient statement. The dose does not show an error until I try to build a project.
I think I read somewhere that these two namespaces are not implemented in the new version. If so, is there an alternative way to do this, or am I missing a dependency or using an operator?
code:
public static DataTable GetLog(string appName) { DataTable table = new DataTable("ApplicationLog"); SqlDataAdapter da = null; using (SqlConnection conn = DB.GetSqlConnection()) { SqlCommand cmd = new SqlCommand("select * from ApplicationLog where application_name = @appname", conn); cmd.Parameters.Add(new SqlParameter("appname", System.Data.SqlDbType.NVarChar, 100)); cmd.Parameters["appname"].Value = appName; da = new SqlDataAdapter(cmd); int res = da.Fill(table); } return table; }
my project.json
{ "userSecretsId": "aspnet5-ASPDemo-b25bb1cc-00e6-401e-9f49-5b59c08a030f", "version": "1.0.0-*", "compilationOptions": { "emitEntryPoint": true }, "dependencies": { "Bestro": "1.0.0-*", "EntityFramework.Core": "7.0.0-rc1-final", "EntityFramework.Commands": "7.0.0-rc1-final", "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final", "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1", "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final", "Microsoft.Extensions.Logging": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final", "DataTables.AspNet.AspNet5": "2.0.0-beta2" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel", "ef": "EntityFramework.Commands" }, "frameworks": { "dnx451": { "frameworkAssemblies": { "System.configuration": "4.0.0.0", "System.Data": "4.0.0.0" } } }, "exclude": [ "wwwroot", "node_modules" ], "publishExclude": [ "**.user", "**.vspscc" ], "scripts": { "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] } }
In the end, I tried to find many different components to try to execute it. If there are links to use, please let me know.