Thứ Năm, 24 tháng 3, 2016

ProxyCreationEnabled and LazyLoadingEnabled

If DbContext.Configuration.ProxyCreationEnabled is set to false, DbContext will not load child objects for some parent object unless Include method is called on parent object. Setting DbContext.Configuration.LazyLoadingEnabled to true or false will have no impact on its behaviours.

If DbContext.Configuration.ProxyCreationEnabled is set to true, child objects will be loaded automatically, and DbContext.Configuration.LazyLoadingEnabled value will control when child objects are loaded.
Read More »

Thứ Hai, 14 tháng 3, 2016

Sửa lỗi update-database code first "there is already an object named"

update-database -verbose doesn't work because your model has been changed after your data table already existed.
First, make sure there are no changes to the UserProfile class. Then, run:
Add-Migration InitialMigrations -IgnoreChanges
This should generate a blank "InitialMigration" file. Now, add any desired changes to the UserProfile class. Once changes are added, run the update command again:
update-database -verbose
Now the automatic migration will be applied and the table will be altered with your changes
Read More »