c# - The model backing the <Mydb> context has changed since the database was created -
hello every one
i new in
.net mvc3have made connection string in web.config file, connection created. below connection code
<add name="storedb" connectionstring="data source=amit-pc;initial catalog=store;user id=sa;password=****;integrated security=false" providername="system.data.sqlclient" /> after created
dbconfig.csclass file database table connection below code
public class store : dbcontext { public store() { } public dbset<registermodel> myapp { get; set; } public dbset<application> applicationformmodels { get; set; } } there 2 model have created. first registermodel , seconds application model. when run code error occured
the model backing context has changed since database created.
when use 1
dbset<registermodel>table created , curd operation done error occured when create more 1dbset.below screenshots
looking forward inputs
thanks in advance
go
global.asax-->application_start() , add database.setinitializer<yourdbcontext>(null);
when create model code first ef maps database.it creates hash of schema storde in edmmetadata table created database existing databases won’t have edmmetadata table , won’t have has , implementation throw if table missing.
or alternatively can following
protected override void onmodelcreating(system.data.entity.modelconfiguration.modelbuilder modelbuilder) { modelbuilder.includemetadataindatabase = false; } in dbcontext

Comments
Post a Comment