1
I have a wpf application with Entity framework and sql server express...works perfectly on my pc, but when I try to install it on another computer it does not work...the application does not create the database with code Frst of the createIfNotExists() and the app does not open, does not run. The strange thing is that on my pc when I run the app it creates the right bank and runs the application.
my connection string:
<add name="BarberSystem.Properties.Settings.BancoTesteConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=BARBER_DATABASE;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="BARBER_DATABASE" connectionString="data source=.\SQLEXPRESS;initial catalog=BARBER_DATABASE;integrated security=SSPI;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
the builder of my Entity context class
public BancoDados()
: base("name=BARBER_DATABASE") {
Database.SetInitializer(new CreateDatabaseIfNotExists<BancoDados>());
}
Generate a log of your application to see the exception that occurs. In the first instance I would check if the connectionstring is correct on the new machine, but it is better to view the exception log to have information about what is happening internally in the application.
– Renan Malagutti
I have a log class...the message I received in my log was:CREATE DATABASE permission denied in database master
– Eduardo Secolin
So the problem is the permission of the user that the application is using. You need to grant dbcreator permission to the user that your application uses (or in the user group). You can do this through own management studio.
– Renan Malagutti