wpf application with Entity framework does not work on another machine

Asked

Viewed 60 times

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.

  • I have a log class...the message I received in my log was:CREATE DATABASE permission denied in database master

  • 2

    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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.