Searchthe file"C:\ Users\Rocco\Documents\VisualStudio2010
\Projects \Videostore\VideoStore.WebUI\App_Data\VideoStore1.mdf"in
thedirectory failed.Operating system error:5 (Accessis denied.). CREATEDATABASE failed.Unable tocreate some of thelistedfilenames.Check
related errors.
mvc_3
Member
174 Points
128 Posts
Class Initializer..Error
Dec 23, 2011 04:00 PM|LINK
I can implement all this with sql express and not with sql ce?
The method seed:
public class VideoStoreInitializer : DropCreateDatabaseIfModelChanges<EFDbContext> { protected override void Seed(EFDbContext context) { var films=new List<Film> { new Film { Titolo="Cado dalle nubi", Anno=2010, Genere="Comico", CopiaID=1}, new Film { Titolo="La vita è bella", Anno=2003, Genere="Drammatico", CopiaID=2} }; films.ForEach(f=>context.Films.Add(f)); context.SaveChanges(); var copie=new List<Copia> { new Copia { Numero=2, Supporto="VHS"}, new Copia { Numero=3, Supporto="DVD"} }; copie.ForEach(c=>context.Copie.Add(c)); context.SaveChanges(); var attori=new List<Attore> { new Attore{ Nominativo="Checco Zalone", DataNascita="25/05/1990", LuogoNascita="Capurso"}, new Attore{ Nominativo="Benigni", DataNascita="23/4/1940", LuogoNascita="Firenze"} }; attori.ForEach(a=>context.Attori.Add(a)); context.SaveChanges(); var registi=new List<Regista> { new Regista{ Nominativo="Neri Parenti", DataNascita="23/10/1950", LuogoNascita="Roma"}, new Regista{ Nominativo="Giorgio Estrella", DataNascita="29/05/1960", LuogoNascita="Napoli"} }; registi.ForEach(r=>context.Registi.Add(r)); context.SaveChanges(); var clienti=new List<Cliente> { new Cliente{ Nominativo="Luca Rossi", Indirizzo="Via della libertà", Telefono="09923344"}, new Cliente{ Nominativo="Giuseppe Marino", Indirizzo="Corso Roma", Telefono="08222244"}, }; clienti.ForEach(c=>context.Clienti.Add(c)); context.SaveChanges(); } }mvc_3
Member
174 Points
128 Posts
Re: Class Initializer..Error
Dec 23, 2011 04:45 PM|LINK
If changed name of db this the error:
Search the file "C: \ Users \ Rocco \ Documents \ Visual Studio 2010 \ Projects \ Videostore\ VideoStore.WebUI \ App_Data \ VideoStore1.mdf" in the directory failed. Operating system error: 5 (Access is denied.).
CREATE DATABASE failed. Unable to create some of the listed filenames. Check related errors.
What is the problem?
ignatandrei
All-Star
134913 Points
21619 Posts
Moderator
MVP
Re: Class Initializer..Error
Dec 24, 2011 03:22 AM|LINK
Give riights to the folder to be accessed by asp net user ( or by everyone)
mvc_3
Member
174 Points
128 Posts
Re: Class Initializer..Error
Dec 24, 2011 08:44 AM|LINK
I understand, and how to do this?
ignatandrei
All-Star
134913 Points
21619 Posts
Moderator
MVP
Re: Class Initializer..Error
Dec 24, 2011 08:59 AM|LINK
right click the folder, properties. Security tab, add
mvc_3
Member
174 Points
128 Posts
Re: Class Initializer..Error
Dec 24, 2011 09:01 AM|LINK
In Add, What name I must insert? ASP.NET?
ignatandrei
All-Star
134913 Points
21619 Posts
Moderator
MVP
Re: Class Initializer..Error
Dec 24, 2011 09:03 AM|LINK
yes. To be more sure, everyone.
mvc_3
Member
174 Points
128 Posts
Re: Class Initializer..Error
Dec 24, 2011 09:04 AM|LINK
I tell me Object not find.
ignatandrei
All-Star
134913 Points
21619 Posts
Moderator
MVP
Re: Class Initializer..Error
Dec 24, 2011 05:12 PM|LINK
mvc_3
Member
174 Points
128 Posts
Re: Class Initializer..Error
Dec 26, 2011 11:10 AM|LINK
The problem the access of folder is resolved, but the problem now is that after create of db, the problem this is again when I start the application
What is the problem?