Is your MVC application .NET Framework-based (not Core)? If so I suggest that you use the Forms Authentication which is used in the MVC4 and before. You will be able to use the Access as a store of user information if you can develop a custom membership provider for the Access.
Change Database from SQL Server to MS Access in ASP.NET MVC Project
I have developed ASP.NET MVC Project using Database created in SQL Server
I am using Database first, so I create models from database
I want to change database source from SQL Server to Microsoft Access
This the Connection string in Config file:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=DatabaseName;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="DatabaseNameEntities" connectionString="metadata=res://*/DatabaseNameModel.csdl|res://*/DatabaseNameModel.ssdl|res://*/DatabaseNameModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=DatabaseName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
The problem is that ASP.NET Project create the User model by code first, but I do need that as I created the User table in database so I not need to create it by code first
The Problem in that Connection String:
<add name="DatabaseNameEntities" connectionString="metadata=res://*/DatabaseNameModel.csdl|res://*/DatabaseNameModel.ssdl|res://*/DatabaseNameModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=DatabaseName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Developer technologies ASP.NET Other
2 answers
Sort by: Most helpful
-
-
Lan Huang-MSFT 30,186 Reputation points Microsoft External Staff
2022-04-04T06:37:31.667+00:00 Hi @mostafa ahmed ,
You can refer to the following line for theconnectionstring
.
https://learn.microsoft.com/en-us/dotnet/api/system.data.oledb.oledbconnection.connectionstring?view=dotnet-plat-ext-6.0#system-data-oledb-oledbconnection-connectionstringProvider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;Jet OLEDB:Database Password=MyDbPassword;
Note: EF does not work with Access and does not support OLEDB connections.
Microsoft strongly recommends against using Access in Web applications. For details, you can see the documentation.
https://learn.microsoft.com/en-us/previous-versions/aspnet/jj653753(v=vs.110)?redirectedfrom=MSDN#can-my-aspnet-web-application-use-a-microsoft-access-database
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.