c# - Database not getting created on EntityFramework-CodeFirst Approach -
i new entityframework.i trying create database using codefirst approach of entityframework. have code in dal layer here :
[table("category")] public class category { [key] public int categoryid { get; set; } [required] [column(typename="varchar")] [stringlength(200)] public string categoryname { get; set; } } public class databasecontext:dbcontext { public databasecontext() : base("dbconnection") { //added following still doesnt work //database.setinitializer<databasecontext>(new createdatabaseifnotexists<databasecontext>()); } public dbset<category> categories { get; set; } }
connection string in app.config file of dal layer
<connectionstrings> <add name="dbconnection" connectionstring="data source=(localdb)\v11.0;initial catalog=dbpdtcgry;uid=admin;password=admin123;" providername="system.data.sqlclient"></add>
this not create database in sql server management.but dbconnection log file & mdf file
created in the app_data , able add,update , delete data.
am missing thing here??
may missed server=localhost\sqlserverinstancename in connection string, because of db created on app_data not in default folder of sql server
Comments
Post a Comment